<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>👍docker入门看这一篇就够了 | iworkh blog</title>
  
    <meta name="keywords" content=" docker ">
  
  <meta name="description" content="👍docker入门看这一篇就够了 | iworkh blog">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="description" content="个人简介沐雨云楼，程序员一名。 喜欢研究技术，主要从事JAVA、微服务、大数据领域。 联系方式 QQ : 157162006 邮箱 :157162006@qq.com">
<meta property="og:type" content="website">
<meta property="og:title" content="关于">
<meta property="og:url" content="https://iworkh.gitee.io/blog/about/index.html">
<meta property="og:site_name" content="iworkh blog">
<meta property="og:description" content="个人简介沐雨云楼，程序员一名。 喜欢研究技术，主要从事JAVA、微服务、大数据领域。 联系方式 QQ : 157162006 邮箱 :157162006@qq.com">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-05-17T07:22:16.000Z">
<meta property="article:modified_time" content="2020-09-12T13:21:47.523Z">
<meta property="article:author" content="沐雨云楼">
<meta property="article:tag" content="iworkh">
<meta property="article:tag" content="沐雨云楼">
<meta property="article:tag" content="blog">
<meta name="twitter:card" content="summary">


<link rel="icon" href="/blog/img/iwork.svg">

<link href="/blog/css/style.css?v=1.0.1" rel="stylesheet">

<link href="/blog/css/hl_theme/atom-light.css?v=1.0.1" rel="stylesheet">

<link href="//cdn.bootcdn.net/ajax/libs/animate.css/4.1.0/animate.min.css" rel="stylesheet">
<link href="//cdn.bootcdn.net/ajax/libs/font-awesome/5.13.0/js/fontawesome.min.js" rel="stylesheet">

<script src="//cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="/blog/js/jquery.autocomplete.min.js?v=1.0.1" ></script>
<script src="/blog/js/titleTip.js?v=1.0.1" ></script>

<script src="//cdn.bootcdn.net/ajax/libs/highlight.js/10.0.3/highlight.min.js"></script>
<script>
    hljs.initHighlightingOnLoad();
</script>

<script src="//cdn.bootcdn.net/ajax/libs/nprogress/0.2.0/nprogress.min.js"></script>



<script src="//cdn.bootcdn.net/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js" ></script>

<script src="/blog/js/iconfont.js?v=1.0.1" ></script>

<meta name="generator" content="Hexo 4.2.1"></head>
<div style="display: none">
  <input class="theme_disqus_on" value="false">
  <input class="theme_preload_comment" value="false">
  <input class="theme_blog_path" value="/blog">
</div>




<body>
<aside class="nav">
    <div class="nav-left">
        <a href="/blog/" class="avatar_target">
    <img class="avatar" src="/blog/img/iwork.svg" />
</a>
<div class="author">
    <span>沐雨云楼</span>
</div>

<div class="icon">
    
        
        <a title="github" href="https://gitee.com/iworkh" target="_blank">
            
                <svg class="iconfont-svg" aria-hidden="true">
                    <use xlink:href="#icon-github"></use>
                </svg>
            
        </a>
        
    
        
        <a title="csdn" href="https://blog.csdn.net/u011622109" target="_blank">
            
                <svg class="iconfont-svg" aria-hidden="true">
                    <use xlink:href="#icon-csdn"></use>
                </svg>
            
        </a>
        
    
        
        <a title="email" href="mailto:157162006@qq.com" target="_blank">
            
                <svg class="iconfont-svg" aria-hidden="true">
                    <use xlink:href="#icon-email"></use>
                </svg>
            
        </a>
        
    
        
        <a title="qq" href="http://wpa.qq.com/msgrd?v=3&uin=157162006&site=qq&menu=yes" target="_blank">
            
                <svg class="iconfont-svg" aria-hidden="true">
                    <use xlink:href="#icon-qq"></use>
                </svg>
            
        </a>
        
    
        
        <a title="kugou" href="https://www.kugou.com/" target="_blank">
            
                <svg class="iconfont-svg" aria-hidden="true">
                    <use xlink:href="#icon-kugou"></use>
                </svg>
            
        </a>
        
    
        
        <a title="neteasemusic" href="https://music.163.com/" target="_blank">
            
                <svg class="iconfont-svg" aria-hidden="true">
                    <use xlink:href="#icon-neteasemusic"></use>
                </svg>
            
        </a>
        
    
</div>



<a class="more-menus">更多菜单</a>


<ul>
    <li><div class="all active">全部文章<small>(85)</small></div></li>
    
        
            
            <li><div data-rel="手册"><i class="fold iconfont icon-right"></i>手册<small>(2)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="iworkh">iworkh<small>(1)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="pgmanor">pgmanor<small>(1)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="工具"><i class="fold iconfont icon-right"></i>工具<small>(16)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="git">git<small>(2)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="github">github<small>(1)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="hexo">hexo<small>(1)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="idea">idea<small>(2)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="markdowm">markdowm<small>(1)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="maven">maven<small>(1)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="有道云">有道云<small>(1)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="java"><i class="fold iconfont icon-right"></i>java<small>(20)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="dao">dao<small>(6)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="jvm">jvm<small>(1)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="test">test<small>(5)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="tools">tools<small>(3)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="并发">并发<small>(1)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="微服务"><i class="fold iconfont icon-right"></i>微服务<small>(6)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="spring">spring<small>(2)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="springboot">springboot<small>(3)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="架构">架构<small>(2)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="大数据"><i class="fold iconfont icon-right"></i>大数据<small>(4)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="hadoop">hadoop<small>(1)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="spark">spark<small>(3)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="web"><i class="fold iconfont icon-right"></i>web<small>(3)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="vue">vue<small>(2)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="db"><i class="fold iconfont icon-right"></i>db<small>(4)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="mysql">mysql<small>(3)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="redis">redis<small>(1)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="ai">ai<small>(4)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="python"><i class="fold iconfont icon-right"></i>python<small>(8)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="tornado">tornado<small>(3)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="linux"><i class="fold iconfont icon-right"></i>linux<small>(2)</small></div>
                
                    <ul class="sub hide">
                        
                        <li><div data-rel="docker">docker<small>(1)</small></div>
                            
                        </li>
                            
                        <li><div data-rel="nginx">nginx<small>(1)</small></div>
                            
                        </li>
                            
                    </ul>
                
            </li>
            
        
    
        
            
            <li><div data-rel="windows">windows<small>(3)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="结构和算法">结构和算法<small>(8)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="面试">面试<small>(2)</small></div>
                
            </li>
            
        
    
        
            
            <li><div data-rel="其他">其他<small>(1)</small></div>
                
            </li>
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
        
            
        
    
</ul>
<div class="left-bottom">
    <div class="menus">
    
    
    
    <a class="dynamic-menu " target="_blank"  href="https://pgmanor.gitee.io/blog/">pgmanor</a>
    
    
    <a class="dynamic-menu " target="_blank"  href="https://www.iworkh.com/manualIt/Category/scopeDev/">iworkh</a>
    
    
    <a class="dynamic-menu " target="_blank"  href="https://gitee.com/iworkh">gitee</a>
    
    </div>
    <div><a class="about  hasFriend  site_url"  href="/blog/about">关于</a><a style="width: 50%"  class="friends">友链</a></div>
</div>
<input type="hidden" id="iworkh_site_posts_number" value="85">
<input type="hidden" id="iworkh_site_word_count" value="197.8k">
<div style="display: none">
    <span id="busuanzi_value_site_uv"></span>
    <span id="busuanzi_value_site_pv"></span>
</div>

    </div>
    <div class="nav-right">
        <div class="friends-area">
    <div class="friends-title">
        友情链接
        <i class="back-title-list"></i>
    </div>
    <div class="friends-content">
        <ul>
            
            <li><a target="_blank" href="https://www.iworkh.com">iworkh</a></li>
            
            <li><a target="_blank" href="https://www.iworkh.com/download/share/">下载地址</a></li>
            
            <li><a target="_blank" href="http://yelog.org/">叶落阁</a></li>
            
        </ul>
    </div>
</div>
        <div class="title-list">
    <form onkeydown="if(event.keyCode === 13){return false;}">
        <input id="local-search-input" class="search" type="text" placeholder="in: 开头全文搜索" />
        <i class="cross"></i>
        <span>
            <label for="tagswitch">T:</label>
            <input id="tagswitch" type="checkbox" style="display: none" />
            <i id="tagsWitchIcon"></i>
        </span>
    </form>
    <div class="tags-list">
    
    <li class="article-tag-list-item">
        <a class="color3">ai</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">attr</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">aysnc</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">beanmap</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">bigdecimal</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">blog</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">chrome</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">dict</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">dll</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">docker</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">domain</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">fastjson</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">func</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">git</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">github</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">hadoop</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">hexo</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">idea</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">iworkh</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">jackson</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">java</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">jdni</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">jfinalshell</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">joplin</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">JPA</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">lock</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">markdowm</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">maven</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">mock</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">mq</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">mycat</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">mysql</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">nginx</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">notebook</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">plan</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">powermock</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color2">python</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">redis</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">rest</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">sharding-jdbc</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">spark</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">springboot</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">test</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">tool</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">tools</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">tornado</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">transactional</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">web</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">windows</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">wtforms</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">zookeeper</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">分库分表</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">分页</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">命令</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">工具</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">并发</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">序列化</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">微服务</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">性能分析</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">手册</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color4">有道云</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">标签</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">模板</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color5">百度云盘</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color1">结构和算法</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">计划</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">迁移</a>
    </li>
    
    <li class="article-tag-list-item">
        <a class="color3">面试</a>
    </li>
    
    <div class="clearfix"></div>
</div>

    
    <div id="local-search-result">

    </div>
    
    <nav id="title-list-nav">
        
        <a id="top" class="手册 pgmanor "
           href="/blog/2020/12/15/redirect-to-pgmanor/"
           data-tag="迁移"
           data-author="沐雨云楼" >
            <span class="post-title" title="😘博客迁移">😘博客迁移</span>
            <span class="post-date" title="2020-12-15 23:47:55">2020/12/15</span>
        </a>
        
        <a id="top" class="手册 iworkh "
           href="/blog/2020/05/27/manual-iworkh/"
           data-tag="手册,iworkh"
           data-author="沐雨云楼" >
            <span class="post-title" title="iworkh所有手册">iworkh所有手册</span>
            <span class="post-date" title="2020-05-27 21:37:04">2020/05/27</span>
        </a>
        
        <a id="top" class="微服务 springboot "
           href="/blog/2020/06/27/spring_boot_all_resources/"
           data-tag="springboot"
           data-author="沐雨云楼" >
            <span class="post-title" title="Spring Boot全网优质教程汇总">Spring Boot全网优质教程汇总</span>
            <span class="post-date" title="2020-06-27 17:43:13">2020/06/27</span>
        </a>
        
        <a id="top" class="工具 "
           href="/blog/2020/06/22/baidu-pandisk-share/"
           data-tag="百度云盘"
           data-author="沐雨云楼" >
            <span class="post-title" title="百度云盘分享链接">百度云盘分享链接</span>
            <span class="post-date" title="2020-06-22 18:38:21">2020/06/22</span>
        </a>
        
        <a id="top" class="工具 "
           href="/blog/2020/06/21/tool_blogs_all/"
           data-tag="blog"
           data-author="沐雨云楼" >
            <span class="post-title" title="优质博客和文章">优质博客和文章</span>
            <span class="post-date" title="2020-06-21 20:02:14">2020/06/21</span>
        </a>
        
        <a id="top" class="java jvm "
           href="/blog/2020/06/04/java-online-analysis/"
           data-tag="性能分析"
           data-author="沐雨云楼" >
            <span class="post-title" title="JAVA线上故障排查全套路">JAVA线上故障排查全套路</span>
            <span class="post-date" title="2020-06-04 20:34:05">2020/06/04</span>
        </a>
        
        <a id="top" class="工具 idea "
           href="/blog/2020/05/31/jetbrains-idea/"
           data-tag="工具,idea"
           data-author="沐雨云楼" >
            <span class="post-title" title="idea使用技巧">idea使用技巧</span>
            <span class="post-date" title="2020-05-31 16:12:30">2020/05/31</span>
        </a>
        
        <a id="top" class="工具 有道云 "
           href="/blog/2020/05/18/youdao_config_edit/"
           data-tag="工具,有道云"
           data-author="沐雨云楼" >
            <span class="post-title" title="有道云配置修改">有道云配置修改</span>
            <span class="post-date" title="2020-05-18 21:37:04">2020/05/18</span>
        </a>
        
        <a id="top" class="web "
           href="/blog/2020/06/01/web-tools/"
           data-tag="web,tool"
           data-author="沐雨云楼" >
            <span class="post-title" title="前端常用工具">前端常用工具</span>
            <span class="post-date" title="2020-06-01 21:37:04">2020/06/01</span>
        </a>
        
        <a  class="工具 "
           href="/blog/2020/10/25/tool-linux-jfinalshell/"
           data-tag="jfinalshell"
           data-author="沐雨云楼" >
            <span class="post-title" title="linux连接工具jfinalshell">linux连接工具jfinalshell</span>
            <span class="post-date" title="2020-10-25 10:24:59">2020/10/25</span>
        </a>
        
        <a  class="微服务 springboot "
           href="/blog/2020/10/06/spring-boot-multi-profiles/"
           data-tag="springboot"
           data-author="沐雨云楼" >
            <span class="post-title" title="springboot多环境配置打包">springboot多环境配置打包</span>
            <span class="post-date" title="2020-10-06 21:36:42">2020/10/06</span>
        </a>
        
        <a  class="web vue "
           href="/blog/2020/10/06/vue_springboot_package_publish/"
           data-tag="maven"
           data-author="沐雨云楼" >
            <span class="post-title" title="vue+springboot打包发布">vue+springboot打包发布</span>
            <span class="post-date" title="2020-10-06 14:22:29">2020/10/06</span>
        </a>
        
        <a  class="java dao "
           href="/blog/2020/10/06/java-jpa-query/"
           data-tag="JPA"
           data-author="沐雨云楼" >
            <span class="post-title" title="JPA自定义sql">JPA自定义sql</span>
            <span class="post-date" title="2020-10-06 10:20:38">2020/10/06</span>
        </a>
        
        <a  class="微服务 spring "
           href="/blog/2020/10/03/spring-pageable/"
           data-tag="分页"
           data-author="沐雨云楼" >
            <span class="post-title" title="vue+springboot分页交互">vue+springboot分页交互</span>
            <span class="post-date" title="2020-10-03 11:08:21">2020/10/03</span>
        </a>
        
        <a  class="工具 "
           href="/blog/2020/10/02/chrome-plugin/"
           data-tag="chrome"
           data-author="沐雨云楼" >
            <span class="post-title" title="chrome插件">chrome插件</span>
            <span class="post-date" title="2020-10-02 10:11:31">2020/10/02</span>
        </a>
        
        <a  class="windows "
           href="/blog/2020/10/01/windows-less-dll/"
           data-tag="dll"
           data-author="沐雨云楼" >
            <span class="post-title" title="windows缺少dll">windows缺少dll</span>
            <span class="post-date" title="2020-10-01 20:22:28">2020/10/01</span>
        </a>
        
        <a  class="java "
           href="/blog/2020/09/13/java-base-bigdecimal/"
           data-tag="bigdecimal"
           data-author="沐雨云楼" >
            <span class="post-title" title="BigDecimal正确使用了吗?">BigDecimal正确使用了吗?</span>
            <span class="post-date" title="2020-09-13 10:28:54">2020/09/13</span>
        </a>
        
        <a  class="windows "
           href="/blog/2020/09/12/windows-dev-install/"
           data-tag="windows"
           data-author="沐雨云楼" >
            <span class="post-title" title="windows开发环境安装">windows开发环境安装</span>
            <span class="post-date" title="2020-09-12 21:39:01">2020/09/12</span>
        </a>
        
        <a  class="工具 "
           href="/blog/2020/09/06/tool-notebook-joplin/"
           data-tag="joplin"
           data-author="沐雨云楼" >
            <span class="post-title" title="joplin笔记">joplin笔记</span>
            <span class="post-date" title="2020-09-06 20:50:55">2020/09/06</span>
        </a>
        
        <a  class="web vue "
           href="/blog/2020/09/05/vue-element-admin/"
           data-tag="web"
           data-author="沐雨云楼" >
            <span class="post-title" title="vue element admin开发">vue element admin开发</span>
            <span class="post-date" title="2020-09-05 11:01:38">2020/09/05</span>
        </a>
        
        <a  class="工具 "
           href="/blog/2020/09/05/tool-notebook/"
           data-tag="notebook"
           data-author="沐雨云楼" >
            <span class="post-title" title="常见笔记软件">常见笔记软件</span>
            <span class="post-date" title="2020-09-05 10:54:34">2020/09/05</span>
        </a>
        
        <a  class="java dao "
           href="/blog/2020/08/30/java-dao-shardingSphere/"
           data-tag="sharding-jdbc"
           data-author="沐雨云楼" >
            <span class="post-title" title="分库分表中间件-ShardingSphere">分库分表中间件-ShardingSphere</span>
            <span class="post-date" title="2020-08-30 21:52:45">2020/08/30</span>
        </a>
        
        <a  class="java dao "
           href="/blog/2020/08/30/java-dao-mycat/"
           data-tag="mycat"
           data-author="沐雨云楼" >
            <span class="post-title" title="分库分表中间件-MyCat">分库分表中间件-MyCat</span>
            <span class="post-date" title="2020-08-30 15:01:59">2020/08/30</span>
        </a>
        
        <a  class="java dao "
           href="/blog/2020/08/30/java-dao-sharding-db/"
           data-tag="分库分表"
           data-author="沐雨云楼" >
            <span class="post-title" title="分库分表中间件-开源产品">分库分表中间件-开源产品</span>
            <span class="post-date" title="2020-08-30 09:37:18">2020/08/30</span>
        </a>
        
        <a  class="java dao "
           href="/blog/2020/08/29/java-jndi/"
           data-tag="jdni"
           data-author="沐雨云楼" >
            <span class="post-title" title="JNDI">JNDI</span>
            <span class="post-date" title="2020-08-29 17:12:03">2020/08/29</span>
        </a>
        
        <a  class="工具 git "
           href="/blog/2020/08/27/tool-git-setting/"
           data-tag="git"
           data-author="沐雨云楼" >
            <span class="post-title" title="git配置">git配置</span>
            <span class="post-date" title="2020-08-27 21:30:17">2020/08/27</span>
        </a>
        
        <a  class="java test "
           href="/blog/2020/08/23/java-powermock/"
           data-tag="powermock"
           data-author="沐雨云楼" >
            <span class="post-title" title="powermock测试框架">powermock测试框架</span>
            <span class="post-date" title="2020-08-23 12:45:17">2020/08/23</span>
        </a>
        
        <a  class="java test "
           href="/blog/2020/08/23/java-mockito/"
           data-tag="mock"
           data-author="沐雨云楼" >
            <span class="post-title" title="👍mockito测试框架">👍mockito测试框架</span>
            <span class="post-date" title="2020-08-23 10:45:17">2020/08/23</span>
        </a>
        
        <a  class="java test "
           href="/blog/2020/08/22/java-test-ng/"
           data-tag="test"
           data-author="沐雨云楼" >
            <span class="post-title" title="👍TestNG一篇足以">👍TestNG一篇足以</span>
            <span class="post-date" title="2020-08-22 18:37:28">2020/08/22</span>
        </a>
        
        <a  class="db mysql "
           href="/blog/2020/08/19/mysql-common-sql/"
           data-tag="mysql"
           data-author="沐雨云楼" >
            <span class="post-title" title="mysql常用sql">mysql常用sql</span>
            <span class="post-date" title="2020-08-19 21:30:00">2020/08/19</span>
        </a>
        
        <a  class="db mysql "
           href="/blog/2020/08/19/mysql-windows-zip-install/"
           data-tag="mysql"
           data-author="沐雨云楼" >
            <span class="post-title" title="mysql zip在windows上安装">mysql zip在windows上安装</span>
            <span class="post-date" title="2020-08-19 21:00:47">2020/08/19</span>
        </a>
        
        <a  class="工具 idea "
           href="/blog/2020/08/15/jetbrains-crack/"
           data-tag="工具,idea"
           data-author="沐雨云楼" >
            <span class="post-title" title="jetbrains全家桶破解">jetbrains全家桶破解</span>
            <span class="post-date" title="2020-08-15 19:22:33">2020/08/15</span>
        </a>
        
        <a  class="工具 git "
           href="/blog/2020/07/10/tool-git-error-name-too-long/"
           data-tag="git"
           data-author="沐雨云楼" >
            <span class="post-title" title="git文件名太长">git文件名太长</span>
            <span class="post-date" title="2020-07-10 12:03:02">2020/07/10</span>
        </a>
        
        <a  class="db mysql "
           href="/blog/2020/07/04/mysql-lock-unlock-table/"
           data-tag="lock"
           data-author="沐雨云楼" >
            <span class="post-title" title="mysql数据库锁查询和释放">mysql数据库锁查询和释放</span>
            <span class="post-date" title="2020-07-04 21:46:54">2020/07/04</span>
        </a>
        
        <a  class="结构和算法 "
           href="/blog/2020/07/04/data-structures-algorithms-sort/"
           data-tag="结构和算法"
           data-author="沐雨云楼" >
            <span class="post-title" title="数据结构和算法8-排序">数据结构和算法8-排序</span>
            <span class="post-date" title="2020-07-04 18:49:12">2020/07/04</span>
        </a>
        
        <a  class="结构和算法 "
           href="/blog/2020/07/04/data-structures-algorithms-search/"
           data-tag="结构和算法"
           data-author="沐雨云楼" >
            <span class="post-title" title="数据结构和算法7-搜索">数据结构和算法7-搜索</span>
            <span class="post-date" title="2020-07-04 17:48:19">2020/07/04</span>
        </a>
        
        <a  class="结构和算法 "
           href="/blog/2020/07/04/data-structures-algorithms-graph/"
           data-tag="结构和算法"
           data-author="沐雨云楼" >
            <span class="post-title" title="数据结构和算法6-非线性-图">数据结构和算法6-非线性-图</span>
            <span class="post-date" title="2020-07-04 16:09:47">2020/07/04</span>
        </a>
        
        <a  class="结构和算法 "
           href="/blog/2020/07/04/data-structures-algorithms-tree/"
           data-tag="结构和算法"
           data-author="沐雨云楼" >
            <span class="post-title" title="数据结构和算法5-非线性-树">数据结构和算法5-非线性-树</span>
            <span class="post-date" title="2020-07-04 15:09:47">2020/07/04</span>
        </a>
        
        <a  class="结构和算法 "
           href="/blog/2020/07/04/data-structures-algorithms-linear-queue/"
           data-tag="结构和算法"
           data-author="沐雨云楼" >
            <span class="post-title" title="数据结构和算法4-线性-队列">数据结构和算法4-线性-队列</span>
            <span class="post-date" title="2020-07-04 14:10:22">2020/07/04</span>
        </a>
        
        <a  class="结构和算法 "
           href="/blog/2020/07/04/data-structures-algorithms-linear-stack/"
           data-tag="结构和算法"
           data-author="沐雨云楼" >
            <span class="post-title" title="数据结构和算法3-线性-栈">数据结构和算法3-线性-栈</span>
            <span class="post-date" title="2020-07-04 13:00:17">2020/07/04</span>
        </a>
        
        <a  class="结构和算法 "
           href="/blog/2020/07/04/data-structures-algorithms-linear-list/"
           data-tag="结构和算法"
           data-author="沐雨云楼" >
            <span class="post-title" title="数据结构和算法2-线性-链">数据结构和算法2-线性-链</span>
            <span class="post-date" title="2020-07-04 11:32:12">2020/07/04</span>
        </a>
        
        <a  class="结构和算法 "
           href="/blog/2020/07/04/data-structures-algorithms-info/"
           data-tag="结构和算法"
           data-author="沐雨云楼" >
            <span class="post-title" title="数据结构和算法1-介绍">数据结构和算法1-介绍</span>
            <span class="post-date" title="2020-07-04 10:10:40">2020/07/04</span>
        </a>
        
        <a  class="大数据 spark "
           href="/blog/2020/06/30/spark-install-windows/"
           data-tag="spark"
           data-author="沐雨云楼" >
            <span class="post-title" title="spark开发环境搭建">spark开发环境搭建</span>
            <span class="post-date" title="2020-06-30 19:24:51">2020/06/30</span>
        </a>
        
        <a  class="大数据 hadoop "
           href="/blog/2020/06/30/hadoop-install-windows/"
           data-tag="hadoop"
           data-author="沐雨云楼" >
            <span class="post-title" title="hadoop开发环境搭建">hadoop开发环境搭建</span>
            <span class="post-date" title="2020-06-30 18:06:23">2020/06/30</span>
        </a>
        
        <a  class="java "
           href="/blog/2020/06/30/java-install-windows/"
           data-tag="java"
           data-author="沐雨云楼" >
            <span class="post-title" title="jdk开发环境搭建">jdk开发环境搭建</span>
            <span class="post-date" title="2020-06-30 15:09:34">2020/06/30</span>
        </a>
        
        <a  class="ai "
           href="/blog/2020/06/30/ai-python-spark-env/"
           data-tag="spark"
           data-author="沐雨云楼" >
            <span class="post-title" title="python spark开发环境搭建">python spark开发环境搭建</span>
            <span class="post-date" title="2020-06-30 12:14:04">2020/06/30</span>
        </a>
        
        <a  class="ai "
           href="/blog/2020/06/29/ai-jupyter-notebook/"
           data-tag="标签"
           data-author="沐雨云楼" >
            <span class="post-title" title="jupyter notebook">jupyter notebook</span>
            <span class="post-date" title="2020-06-29 12:29:36">2020/06/29</span>
        </a>
        
        <a  class="ai "
           href="/blog/2020/06/26/ai-python-tools/"
           data-tag="tools"
           data-author="沐雨云楼" >
            <span class="post-title" title="python和ai常用工具">python和ai常用工具</span>
            <span class="post-date" title="2020-06-26 09:55:24">2020/06/26</span>
        </a>
        
        <a  class="python "
           href="/blog/2020/06/25/python-tool-buildin-attr/"
           data-tag="attr"
           data-author="沐雨云楼" >
            <span class="post-title" title="👍python内置属性(魔法方法)">👍python内置属性(魔法方法)</span>
            <span class="post-date" title="2020-06-25 11:01:33">2020/06/25</span>
        </a>
        
        <a  class="python "
           href="/blog/2020/06/24/python-tool-buildin-func/"
           data-tag="func"
           data-author="沐雨云楼" >
            <span class="post-title" title="👍python内置函数">👍python内置函数</span>
            <span class="post-date" title="2020-06-24 18:31:59">2020/06/24</span>
        </a>
        
        <a  class="python "
           href="/blog/2020/06/24/python-tool-obj-dict/"
           data-tag="dict"
           data-author="沐雨云楼" >
            <span class="post-title" title="python对象与dict互转">python对象与dict互转</span>
            <span class="post-date" title="2020-06-24 18:15:03">2020/06/24</span>
        </a>
        
        <a  class="大数据 spark "
           href="/blog/2020/06/21/spark-version-3/"
           data-tag="spark"
           data-author="沐雨云楼" >
            <span class="post-title" title="spark3.0新特性">spark3.0新特性</span>
            <span class="post-date" title="2020-06-21 17:40:12">2020/06/21</span>
        </a>
        
        <a  class="java "
           href="/blog/2020/06/21/java-base-domain/"
           data-tag="domain"
           data-author="沐雨云楼" >
            <span class="post-title" title="VO DTO DO PO你都了解吗?">VO DTO DO PO你都了解吗?</span>
            <span class="post-date" title="2020-06-21 09:20:03">2020/06/21</span>
        </a>
        
        <a  class="大数据 spark "
           href="/blog/2020/06/20/spark-data-skew/"
           data-tag="spark"
           data-author="沐雨云楼" >
            <span class="post-title" title="spark数据倾斜及解决方案">spark数据倾斜及解决方案</span>
            <span class="post-date" title="2020-06-20 21:41:12">2020/06/20</span>
        </a>
        
        <a  class="linux nginx "
           href="/blog/2020/06/20/nginx-fast/"
           data-tag="nginx"
           data-author="沐雨云楼" >
            <span class="post-title" title="nginx为何这么快?">nginx为何这么快?</span>
            <span class="post-date" title="2020-06-20 17:55:10">2020/06/20</span>
        </a>
        
        <a  class="架构 "
           href="/blog/2020/06/20/fw-mq-message-missing/"
           data-tag="mq"
           data-author="沐雨云楼" >
            <span class="post-title" title="MQ如何保证消息不丢失?">MQ如何保证消息不丢失?</span>
            <span class="post-date" title="2020-06-20 17:03:18">2020/06/20</span>
        </a>
        
        <a  class="java "
           href="/blog/2020/06/20/java-base-serializable/"
           data-tag="序列化"
           data-author="沐雨云楼" >
            <span class="post-title" title="java序列化">java序列化</span>
            <span class="post-date" title="2020-06-20 16:29:04">2020/06/20</span>
        </a>
        
        <a  class="架构 "
           href="/blog/2020/06/20/fw-distributed-lock-redis-zk/"
           data-tag="lock,redis,zookeeper"
           data-author="沐雨云楼" >
            <span class="post-title" title="分布式锁用redis还是zk?">分布式锁用redis还是zk?</span>
            <span class="post-date" title="2020-06-20 12:09:55">2020/06/20</span>
        </a>
        
        <a  class="java tools "
           href="/blog/2020/06/19/java-tool-jackson/"
           data-tag="jackson"
           data-author="沐雨云楼" >
            <span class="post-title" title="工具类--jackson">工具类--jackson</span>
            <span class="post-date" title="2020-06-19 13:00:45">2020/06/19</span>
        </a>
        
        <a  class="java tools "
           href="/blog/2020/06/19/java-tool-bean-map/"
           data-tag="beanmap"
           data-author="沐雨云楼" >
            <span class="post-title" title="工具类--bean和map互转">工具类--bean和map互转</span>
            <span class="post-date" title="2020-06-19 12:30:14">2020/06/19</span>
        </a>
        
        <a  class="java test "
           href="/blog/2020/06/18/java-rest-assured-in-action/"
           data-tag="rest"
           data-author="沐雨云楼" >
            <span class="post-title" title="rest-assured实战">rest-assured实战</span>
            <span class="post-date" title="2020-06-18 17:51:56">2020/06/18</span>
        </a>
        
        <a  class="java test "
           href="/blog/2020/06/17/java_rest_assured_wiki_info/"
           data-tag="rest"
           data-author="沐雨云楼" >
            <span class="post-title" title="rest-assured wiki翻译">rest-assured wiki翻译</span>
            <span class="post-date" title="2020-06-17 20:39:11">2020/06/17</span>
        </a>
        
        <a  class="python tornado "
           href="/blog/2020/06/16/tornado-wtforms/"
           data-tag="wtforms"
           data-author="沐雨云楼" >
            <span class="post-title" title="wtforms表单验证">wtforms表单验证</span>
            <span class="post-date" title="2020-06-16 21:52:33">2020/06/16</span>
        </a>
        
        <a  class="python tornado "
           href="/blog/2020/06/16/tornado-sync-to-async/"
           data-tag="aysnc"
           data-author="沐雨云楼" >
            <span class="post-title" title="tornado同步转异步">tornado同步转异步</span>
            <span class="post-date" title="2020-06-16 21:50:25">2020/06/16</span>
        </a>
        
        <a  class="python tornado "
           href="/blog/2020/06/08/python_tornado_info/"
           data-tag="tornado"
           data-author="沐雨云楼" >
            <span class="post-title" title="👍Tornado入门这一篇足以">👍Tornado入门这一篇足以</span>
            <span class="post-date" title="2020-06-08 20:31:32">2020/06/08</span>
        </a>
        
        <a  class="工具 maven "
           href="/blog/2020/06/07/tool-maven/"
           data-tag="tools,工具"
           data-author="沐雨云楼" >
            <span class="post-title" title="maven常用命令和配置">maven常用命令和配置</span>
            <span class="post-date" title="2020-06-07 16:30:11">2020/06/07</span>
        </a>
        
        <a  class="微服务 springboot "
           href="/blog/2020/06/07/spring-initialzr/"
           data-tag="tools,工具"
           data-author="沐雨云楼" >
            <span class="post-title" title="spring initialzr环境编译发布">spring initialzr环境编译发布</span>
            <span class="post-date" title="2020-06-07 15:06:00">2020/06/07</span>
        </a>
        
        <a  class="windows "
           href="/blog/2020/06/07/windows-cmd/"
           data-tag="tools,工具,命令"
           data-author="沐雨云楼" >
            <span class="post-title" title="windows常用命令和技巧">windows常用命令和技巧</span>
            <span class="post-date" title="2020-06-07 11:39:01">2020/06/07</span>
        </a>
        
        <a  class="工具 github "
           href="/blog/2020/06/07/tool-connect-github/"
           data-tag="github"
           data-author="沐雨云楼" >
            <span class="post-title" title="github无法访问解决办法">github无法访问解决办法</span>
            <span class="post-date" title="2020-06-07 10:08:38">2020/06/07</span>
        </a>
        
        <a  class="微服务 spring "
           href="/blog/2020/06/03/spring-transaction/"
           data-tag="transactional"
           data-author="沐雨云楼" >
            <span class="post-title" title="Transactional注解">Transactional注解</span>
            <span class="post-date" title="2020-06-03 22:09:42">2020/06/03</span>
        </a>
        
        <a  class="java dao "
           href="/blog/2020/06/03/java-jpa-query-multi-param/"
           data-tag="JPA"
           data-author="沐雨云楼" >
            <span class="post-title" title="JPA多条件查询">JPA多条件查询</span>
            <span class="post-date" title="2020-06-03 21:38:04">2020/06/03</span>
        </a>
        
        <a  class="java tools "
           href="/blog/2020/06/02/java-tool-fastjson-bug/"
           data-tag="fastjson"
           data-author="沐雨云楼" >
            <span class="post-title" title="Fastjson远程代码高危漏洞">Fastjson远程代码高危漏洞</span>
            <span class="post-date" title="2020-06-02 22:38:28">2020/06/02</span>
        </a>
        
        <a  class="linux docker "
           href="/blog/2020/06/02/docker-introduction/"
           data-tag="docker"
           data-author="沐雨云楼" >
            <span class="post-title" title="👍docker入门看这一篇就够了">👍docker入门看这一篇就够了</span>
            <span class="post-date" title="2020-06-02 22:22:30">2020/06/02</span>
        </a>
        
        <a  class="面试 "
           href="/blog/2020/06/02/interview-java-question/"
           data-tag="面试"
           data-author="沐雨云楼" >
            <span class="post-title" title="java常见面试题">java常见面试题</span>
            <span class="post-date" title="2020-06-02 22:15:48">2020/06/02</span>
        </a>
        
        <a  class="微服务 "
           href="/blog/2020/06/02/microservice-why/"
           data-tag="微服务"
           data-author="沐雨云楼" >
            <span class="post-title" title="牛逼公司一定要使用微服务？">牛逼公司一定要使用微服务？</span>
            <span class="post-date" title="2020-06-02 21:15:29">2020/06/02</span>
        </a>
        
        <a  class="面试 "
           href="/blog/2020/06/02/interview-company/"
           data-tag="面试"
           data-author="沐雨云楼" >
            <span class="post-title" title="IT互联网公司名单">IT互联网公司名单</span>
            <span class="post-date" title="2020-06-02 20:41:23">2020/06/02</span>
        </a>
        
        <a  class="java 并发 "
           href="/blog/2020/06/02/java-concurrent-aqs/"
           data-tag="java,并发"
           data-author="沐雨云楼" >
            <span class="post-title" title="java并发AQS">java并发AQS</span>
            <span class="post-date" title="2020-06-02 20:01:48">2020/06/02</span>
        </a>
        
        <a  class="ai "
           href="/blog/2020/05/30/ai-learn-catalog/"
           data-tag="ai"
           data-author="沐雨云楼" >
            <span class="post-title" title="AI学习目录">AI学习目录</span>
            <span class="post-date" title="2020-05-30 08:49:39">2020/05/30</span>
        </a>
        
        <a  class="工具 hexo "
           href="/blog/2020/05/29/hexo-theme-math/"
           data-tag="工具,hexo"
           data-author="沐雨云楼" >
            <span class="post-title" title="hexo主题支持MathJax">hexo主题支持MathJax</span>
            <span class="post-date" title="2020-05-29 09:36:46">2020/05/29</span>
        </a>
        
        <a  class="db redis "
           href="/blog/2020/05/28/redis-memory-eliminate/"
           data-tag="redis"
           data-author="沐雨云楼" >
            <span class="post-title" title="Redis的内存淘汰策略">Redis的内存淘汰策略</span>
            <span class="post-date" title="2020-05-28 21:37:04">2020/05/28</span>
        </a>
        
        <a  class="工具 markdowm "
           href="/blog/2020/05/28/markdown-math-express/"
           data-tag="工具,markdowm"
           data-author="沐雨云楼" >
            <span class="post-title" title="markdown数学公式">markdown数学公式</span>
            <span class="post-date" title="2020-05-28 08:02:03">2020/05/28</span>
        </a>
        
        <a  class="python "
           href="/blog/2020/05/21/python_install/"
           data-tag="python"
           data-author="沐雨云楼" >
            <span class="post-title" title="python环境安装">python环境安装</span>
            <span class="post-date" title="2020-05-21 21:37:04">2020/05/21</span>
        </a>
        
        <a  class="python "
           href="/blog/2020/05/21/python_base/"
           data-tag="python"
           data-author="沐雨云楼" >
            <span class="post-title" title="python基本语法">python基本语法</span>
            <span class="post-date" title="2020-05-21 00:00:00">2020/05/21</span>
        </a>
        
        <a  class="其他 "
           href="/blog/2020/05/20/todo-list/"
           data-tag="plan,计划"
           data-author="沐雨云楼" >
            <span class="post-title" title="计划">计划</span>
            <span class="post-date" title="2020-05-20 11:04:19">2020/05/20</span>
        </a>
        
        <a  class="工具 "
           href="/blog/2020/05/20/blog-template/"
           data-tag="模板"
           data-author="沐雨云楼" >
            <span class="post-title" title="博客自定义模板">博客自定义模板</span>
            <span class="post-date" title="2020-05-20 05:20:00">2020/05/20</span>
        </a>
        
    </nav>
</div>

    </div>
    <div class="hide-list">
        <div class="semicircle" data-title="切换全屏 快捷键 s">
            <div class="brackets first"><</div>
            <div class="brackets">&gt;</div>
        </div>
    </div>
</aside>
<div class="post">
    <div class="pjax">
        <article id="post-docker-introduction" class="article article-type-post" itemscope itemprop="blogPost">
    
        <h1 class="article-title">👍docker入门看这一篇就够了</h1>
    
    <div class="article-meta">
        
        
        <span class="author"><a>沐雨云楼</a></span>
        
        
        <span class="book">
            
                <a  data-rel="linux">linux</a>/
            
                <a  data-rel="docker">docker</a>
            
        </span>
        
        
        <span class="tag">
            
            <a class="color2">docker</a>
            
        </span>
        
    </div>
    <div class="article-meta">
        
            发布时间 : <time class="date" title='最后更新: 2020-09-12 21:21:47'>2020-06-02 22:22</time>
        
    </div>
    <div class="article-meta">
        
        <span>字数:10.6k</span>
        
        
        <span id="busuanzi_container_page_pv">
            阅读 :<span id="busuanzi_value_page_pv">
                <span class="count-comment">
                    <span class="spinner">
                      <div class="cube1"></div>
                      <div class="cube2"></div>
                    </span>
                </span>
            </span>
        </span>
        
        
        <span class="top-comment" title="跳转至评论区">
            <a href="#comments">
                评论:<span class="count-comment">
                    <span class="spinner">
                      <div class="cube1"></div>
                      <div class="cube2"></div>
                    </span>
                </span>
            </a>
        </span>
        
    </div>
    
    <div class="article-meta">
        <span class="origin">来源:
            <a href="https://docs.docker.com/engine/reference/builder/" target="_blank">
                
                Dockerfile reference
                
            </a>
        </span>
    </div>
    
    <div class="toc-ref">
    
        <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-容器简介"><span class="toc-text">1.容器简介</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1-什么是Linux容器"><span class="toc-text">1-1.什么是Linux容器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-容器是虚拟化吗"><span class="toc-text">1-2.容器是虚拟化吗</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-3-容器发展简史"><span class="toc-text">1-3.容器发展简史</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-什么是Docker？"><span class="toc-text">2.什么是Docker？</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#2-1-LUX"><span class="toc-text">2-1.LUX</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-2-Docker与Linux容器区别"><span class="toc-text">2-2.Docker与Linux容器区别</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-3-Docker如何工作？"><span class="toc-text">2-3.Docker如何工作？</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-3-1-namespaces"><span class="toc-text">2-3-1.namespaces</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-3-2-controlGroup"><span class="toc-text">2-3-2.controlGroup</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-3-3-流程"><span class="toc-text">2-3-3.流程</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-3-4-架构图"><span class="toc-text">2-3-4.架构图</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-4-docker的目标"><span class="toc-text">2-4.docker的目标</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-安装Docker"><span class="toc-text">3.安装Docker</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#3-1-安装"><span class="toc-text">3-1.安装</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-2-基础命令操作"><span class="toc-text">3-2.基础命令操作</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-3-启动容器"><span class="toc-text">3-3 启动容器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-4-镜像生命周期"><span class="toc-text">3-4.镜像生命周期</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-镜像操作"><span class="toc-text">4 镜像操作</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#4-1-搜索仓库镜像"><span class="toc-text">4-1.搜索仓库镜像</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-2-获取镜像"><span class="toc-text">4-2.获取镜像</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-3-导出镜像"><span class="toc-text">4-3.导出镜像</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-4-删除镜像"><span class="toc-text">4-4.删除镜像</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-5-导入镜像"><span class="toc-text">4-5.导入镜像</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-6-查看镜像详情"><span class="toc-text">4-6.查看镜像详情</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5-容器管理"><span class="toc-text">5.容器管理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#5-1-容器的起-停"><span class="toc-text">5-1.容器的起&#x2F;停</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#5-2-进入容器"><span class="toc-text">5-2.进入容器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#5-3-删除容器"><span class="toc-text">5-3.删除容器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#5-4-启动时端口映射"><span class="toc-text">5-4.启动时端口映射</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#6-数据卷的管理"><span class="toc-text">6.数据卷的管理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#6-1-挂载时创建卷"><span class="toc-text">6-1.挂载时创建卷</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#6-2-创建卷后挂载"><span class="toc-text">6-2.创建卷后挂载</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#6-3-容器保存为镜像"><span class="toc-text">6-3.容器保存为镜像</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#7-Dockerfile"><span class="toc-text">7.Dockerfile</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#7-1-Dockerfile指令集"><span class="toc-text">7-1.Dockerfile指令集</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#7-2-建一个Dockerfile"><span class="toc-text">7-2.建一个Dockerfile</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#7-3-使用Dcokerfile安装kodexplorer"><span class="toc-text">7-3.使用Dcokerfile安装kodexplorer</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#8-镜像分层"><span class="toc-text">8.镜像分层</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#8-1-镜像为什么分层"><span class="toc-text">8-1.镜像为什么分层</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#8-2-可写的容器层"><span class="toc-text">8-2.可写的容器层</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#8-3-容器层细节"><span class="toc-text">8-3.容器层细节</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#9-zabbix-server"><span class="toc-text">9.zabbix-server</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#9-1-容器间的互联"><span class="toc-text">9-1 容器间的互联</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#9-2-启动zabbix容器"><span class="toc-text">9-2.启动zabbix容器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#9-3-zabbix-API"><span class="toc-text">9-3.zabbix API</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#10-docker仓库"><span class="toc-text">10.docker仓库</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#10-1-创建一个普通仓库"><span class="toc-text">10-1.创建一个普通仓库</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#10-2-带basic认证的仓库"><span class="toc-text">10-2.带basic认证的仓库</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#11-docker-compose编排工具"><span class="toc-text">11.docker-compose编排工具</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#11-1-安装docker-compose"><span class="toc-text">11-1.安装docker-compose</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#11-2-编排启动镜像"><span class="toc-text">11-2.编排启动镜像</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#11-3-haproxy代理后端docker容器"><span class="toc-text">11-3.haproxy代理后端docker容器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#11-4-安装socat"><span class="toc-text">11-4 安装socat</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#12-docker重启容器退出"><span class="toc-text">12.docker重启容器退出</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#12-1-自动重启"><span class="toc-text">12-1.自动重启</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-12-2-修改默认配置"><span class="toc-text">1.12.2 修改默认配置</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#13-Docker网络类型"><span class="toc-text">13.Docker网络类型</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#13-1-网络类型"><span class="toc-text">13-1.网络类型</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#13-2-None"><span class="toc-text">13-2.None</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#13-3-Container"><span class="toc-text">13-3.Container</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#13-4-Host"><span class="toc-text">13-4.Host</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#13-5-查看网络列表"><span class="toc-text">13-5.查看网络列表</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#13-6-配置独立IP"><span class="toc-text">13-6.配置独立IP</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-13-7-跨主机通信"><span class="toc-text">1.13.7 跨主机通信</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#14-镜像仓库harbor"><span class="toc-text">14.镜像仓库harbor</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#14-1-建议"><span class="toc-text">14-1.建议</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#14-2-容器的监控"><span class="toc-text">14-2.容器的监控</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#15-参考文献"><span class="toc-text">15.参考文献</span></a></li></ol>
    
<style>
    .left-col .switch-btn,
    .left-col .switch-area {
        display: none;
    }
    .toc-level-4 i,
    .toc-level-4 ol {
        display: none !important;
    }
</style>
</div>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="1-容器简介"><a href="#1-容器简介" class="headerlink" title="1.容器简介"></a>1.容器简介</h2><h3 id="1-1-什么是Linux容器"><a href="#1-1-什么是Linux容器" class="headerlink" title="1-1.什么是Linux容器"></a>1-1.什么是Linux容器</h3><p>Linux容器是与系统其他部分隔离开的一系列进程，从另一个镜像运行，并由该镜像提供支持进程所需的全部文件。容器提供的镜像包含了应用的所有依赖项，因而在从开发到测试再到生产的整个过程中，它都具有可移植性和一致性。</p>
<p><img src="/blog/images/linux/docker/introduction/1190037-20180203180215265-876984278.png" alt="img"></p>
<blockquote>
<p> 更加详细地来说，请您假定您在开发一个应用。您使用的是一台笔记本电脑，而且您的开发环境具有特定的配置。其他开发人员身处的环境配置可能稍有不同。您正在开发的应用依赖于您当前的配置，还要依赖于某些特定文件。与此同时，您的企业还拥有标准化的测试和生产环境，且具有自身的配置和一系列支持文件。您希望尽可能多在本地模拟这些环境，而不产生重新创建服务器环境的开销。</p>
<p> 因此，您要如何确保应用能够在这些环境中运行和通过质量检测，并且在部署过程中不出现令人头疼的问题，也无需重新编写代码和进行故障修复？</p>
<p>答案就是使用容器。容器可以确保您的应用拥有必需的配置和文件，使得这些应用能够在从开发到测试、再到生产的整个流程中顺利运行，而不出现任何不良问题。这样可以避免危机，做到皆大欢喜。</p>
</blockquote>
<p>虽然这只是简化的示例，但在需要很高的可移植性、可配置性和隔离的情况下，我们可以利用 Linux 容器通过很多方式解决难题。无论基础架构是在企业内部还是在云端，或者混合使用两者，容器都能满足您的需求。</p>
<h3 id="1-2-容器是虚拟化吗"><a href="#1-2-容器是虚拟化吗" class="headerlink" title="1-2.容器是虚拟化吗"></a>1-2.容器是虚拟化吗</h3><blockquote>
<p>是，但也不竟然。我们用一种简单方式来思考一下：</p>
</blockquote>
<ul>
<li>虚拟化使得许多操作系统可同时在单个系统上运行。</li>
<li>容器则可共享同一个操作系统内核，将应用进程与系统其他部分隔离开。</li>
</ul>
<p><strong>普通虚拟化技术和Docker的对比</strong></p>
<img src="/blog/images/linux/docker/introduction/lux_vs_docker.png" width="650px">

<ul>
<li><p>普通虚拟机</p>
<ul>
<li>每部一个应用，都得一个Guest OS系统，很重量级（占用cpu、内存、磁盘资源）</li>
</ul>
</li>
<li><p>docker容器</p>
<ul>
<li>只要有需要的Image，就可以基于docker engine进行部署应用，更加轻量级</li>
</ul>
</li>
</ul>
<h3 id="1-3-容器发展简史"><a href="#1-3-容器发展简史" class="headerlink" title="1-3.容器发展简史"></a>1-3.容器发展简史</h3><p><img src="/blog/images/linux/docker/introduction/1190037-20180203180240093-1881375898.png" alt="img"></p>
<p>我们现在称为容器技术的概念最初出现在 2000 年，当时称为 FreeBSD jail，这种技术可将 FreeBSD 系统分区为多个子系统（也称为 Jail）。Jail 是作为安全环境而开发的，系统管理员可与企业内部或外部的多个用户共享这些 Jail。</p>
<p>Jail 的目的是让进程在经过修改的 <em>chroot</em> 环境中创建，而不会脱离和影响整个系统 — 在 chroot 环境中，对文件系统、网络和用户的访问都实现了虚拟化。尽管 Jail 在实施方面存在局限性，但最终人们找到了脱离这种隔离环境的方法。</p>
<p>但这个概念非常有吸引力。</p>
<p>2001 年，通过 Jacques Gélinas 的 VServer 项目，隔离环境的实施进入了 Linux 领域。正如 Gélinas 所说，这项工作的目的是“在高度独立且安全的单一环境中运行多个通用 Linux 服务器 [sic]。” 在完成了这项针对 Linux 中多个受控制用户空间的基础性工作后，Linux 容器开始逐渐成形并最终发展成了现在的模样。</p>
<h2 id="2-什么是Docker？"><a href="#2-什么是Docker？" class="headerlink" title="2.什么是Docker？"></a>2.什么是Docker？</h2><p><strong>Docker</strong>一词指代多种事物，包括开源社区项目、开源项目使用的工具、主导支持此类项目的公司 Docker Inc. 以及该公司官方支持的工具。技术产品和公司使用同一名称，的确让人有点困惑。</p>
<p>我们来简单说明一下：</p>
<blockquote>
<p>🎍 IT 软件中所说的<code>Docker</code> ，是指容器化技术，用于支持创建和使用 Linux 容器。</p>
<p>🎍 开源Docker社区致力于改进这类技术，并免费提供给所有用户，使之获益。</p>
<p>🎍 Docker Inc. 公司凭借Docker社区产品起家，它主要负责提升社区版本的安全性，并将改进后的版本与更广泛的技术社区分享。<br>此外，它还专门对这些技术产品进行完善和安全固化，以服务于企业客户。</p>
</blockquote>
<p>借助 Docker ，您可将容器当做重量轻、模块化的虚拟机使用。同时，您还将获得高度的灵活性，从而实现对容器的高效创建、部署及复制，并能将其从一个环境顺利迁移至另一个环境。</p>
<h3 id="2-1-LUX"><a href="#2-1-LUX" class="headerlink" title="2-1.LUX"></a>2-1.LUX</h3><p>LXC为Linux Container的简写,docker的前生LXC。</p>
<p>可以提供轻量级的虚拟化，以便隔离进程和资源，而且不需要提供指令解释机制以及全虚拟化的其他复杂性。相当于C++中的NameSpace。容器有效地将由单个操作系统管理的资源划分到孤立的组中，以更好地在孤立的组之间平衡有冲突的资源使用需求。</p>
<p>Linux Container提供了在单一可控主机节点上支持多个相互隔离的server container同时执行的机制。Linux Container有点像chroot，提供了一个拥有自己进程和网络空间的虚拟环境，但又有别于虚拟机，因为lxc是一种操作系统层次上的资源的虚拟化。</p>
<p>与传统虚拟化技术相比，它的优势在于：</p>
<ul>
<li>与宿主机使用同一个内核，性能损耗小；</li>
<li>不需要指令级模拟；</li>
<li>不需要即时(Just-in-time)编译；</li>
<li>容器可以在CPU核心的本地运行指令，不需要任何专门的解释机制；</li>
<li>避免了准虚拟化和系统调用替换中的复杂性；</li>
<li>轻量级隔离，在隔离的同时还提供共享机制，以实现容器与宿主机的资源共享。</li>
</ul>
<h3 id="2-2-Docker与Linux容器区别"><a href="#2-2-Docker与Linux容器区别" class="headerlink" title="2-2.Docker与Linux容器区别"></a>2-2.Docker与Linux容器区别</h3><p>Docker技术是否与传统的Linux容器相同？</p>
<blockquote>
<p>否。</p>
</blockquote>
<p>Docker 技术最初是基于<strong>LXC</strong>（linux container）技术构建（大多数人都会将这一技术与“传统的” Linux 容器联系在一起），但后来它逐渐摆脱了对这种技术的依赖。</p>
<p>就<code>轻量级虚拟化</code>这一功能来看，LXC非常有用，但它无法提供出色的开发人员或用户体验。除了运行容器之外，Docker 技术还具备其他多项功能，包括简化用于<strong>构建容器、传输镜像以及控制镜像版本</strong>的流程。</p>
<p><img src="/blog/images/linux/docker/introduction/lux_vs_docker_2.png" alt="img"></p>
<p>传统的Linux容器使用init系统来管理多种进程。这意味着<strong>所有应用程序都作为一个整体运行</strong>。</p>
<p>与此相反，Docker 技术鼓励<strong>应用程序各自独立运行其进程</strong>，并提供相应工具以实现这一功能。这种精细化运作模式自有其优势。</p>
<h3 id="2-3-Docker如何工作？"><a href="#2-3-Docker如何工作？" class="headerlink" title="2-3.Docker如何工作？"></a>2-3.Docker如何工作？</h3><p>Docker技术使用 Linux 内核和内核功能（例如 <strong>Cgroups</strong>和 <strong>namespaces</strong>）来分隔进程，以便各进程相互独立运行。</p>
<p>docker本质就是宿主机的一个进程，docker是通过<strong>namespace</strong>实现资源隔离，通过<strong>cgroup</strong>实现资源限制，通过写时复制技术（copy-on-write）实现了高效的文件操作（类似虚拟机的磁盘比如分配500g并不是实际占用物理磁盘500g）</p>
<ul>
<li><a href="https://draveness.me/docker/" target="_blank" rel="noopener">🐂Docker 核心技术与实现原理</a><blockquote>
<p>如对namespaces和controlGroup到底如何处理隔离的，可以阅读这篇</p>
</blockquote>
</li>
</ul>
<h3 id="2-3-1-namespaces"><a href="#2-3-1-namespaces" class="headerlink" title="2-3-1.namespaces"></a>2-3-1.namespaces</h3><table>
<thead>
<tr>
<th>namespace</th>
<th>系统调用参数</th>
<th>隔离的内容</th>
</tr>
</thead>
<tbody><tr>
<td>UTS</td>
<td>CLONE_NEWUTS</td>
<td>主机名域名</td>
</tr>
<tr>
<td>IPC</td>
<td>CLONE_NEWIPC</td>
<td>信号量、消息队列与共享内存</td>
</tr>
<tr>
<td>PID</td>
<td>CLONE_NEWPID</td>
<td>进程编号</td>
</tr>
<tr>
<td>Network</td>
<td>CLONE_NEWNET</td>
<td>网络设备、网络栈、端口等</td>
</tr>
<tr>
<td>MOUNT</td>
<td>CLONE_NEWNS</td>
<td>挂载点</td>
</tr>
<tr>
<td>USER</td>
<td>CLONE_NEWUSER</td>
<td>用户与组</td>
</tr>
</tbody></table>
<p>更多细节可以参照 <a href="https://www.cnblogs.com/rdchenxi/p/10455831.html" target="_blank" rel="noopener">docker 深入理解之namespace</a></p>
<h3 id="2-3-2-controlGroup"><a href="#2-3-2-controlGroup" class="headerlink" title="2-3-2.controlGroup"></a>2-3-2.controlGroup</h3><p>cgroup的特点是：　　　　　　　</p>
<ul>
<li>cgroup的api以一个伪文件系统的实现方式，用户的程序可以通过文件系统实现cgroup的组件管理</li>
<li>cgroup的组件管理操作单元可以细粒度到线程级别，另外用户可以创建和销毁cgroup，从而实现资源载分配和再利用</li>
<li>所有资源管理的功能都以子系统的方式实现，接口统一子任务创建之初与其父任务处于同一个cgroup的控制组</li>
</ul>
<p>四大功能：　　　　　　　　</p>
<ul>
<li>资源限制：可以对任务使用的资源总额进行限制</li>
<li>优先级分配：通过分配的cpu时间片数量以及磁盘IO带宽大小，实际上相当于控制了任务运行优先级</li>
<li>资源统计：可以统计系统的资源使用量，如cpu时长，内存用量等</li>
<li>任务控制：cgroup可以对任务执行挂起、恢复等操作</li>
</ul>
<h3 id="2-3-3-流程"><a href="#2-3-3-流程" class="headerlink" title="2-3-3.流程"></a>2-3-3.流程</h3><img src="/blog/images/linux/docker/introduction/architecture.svg" width="650px">

<ul>
<li>image镜像<blockquote>
<p>docker镜像就是一个只读模板，比如，一个镜像可以包含一个完整的centos，里面仅安装apache或用户的其他应用，镜像可以用来创建docker容器，另外docker提供了一个很简单的机制来创建镜像或者更新现有的镜像，用户甚至可以直接从其他人那里下周一个已经做好的镜像来直接使用</p>
</blockquote>
</li>
<li>container容器<blockquote>
<p>docker利用容器来运行应用，容器是从镜像创建的运行实例，它可以被启动，开始、停止、删除、每个容器都是互相隔离的，保证安全的平台，可以把容器看做是要给简易版的linux环境（包括root用户权限、镜像空间、用户空间和网络空间等）和运行再其中的应用程序</p>
</blockquote>
</li>
<li>repostory仓库<blockquote>
<p>仓库是集中存储镜像文件的沧桑，registry是仓库主从服务器，实际上参考注册服务器上存放着多个仓库，每个仓库中又包含了多个镜像，每个镜像有不同的标签（tag）。<br>仓库分为两种，公有参考，和私有仓库，最大的公开仓库是docker Hub，存放了数量庞大的镜像供用户下周，国内的docker pool，这里仓库的概念与Git类似，registry可以理解为github这样的托管服务</p>
</blockquote>
</li>
</ul>
<h3 id="2-3-4-架构图"><a href="#2-3-4-架构图" class="headerlink" title="2-3-4.架构图"></a>2-3-4.架构图</h3><p><strong>官网</strong></p>
<p><img src="/blog/images/linux/docker/introduction/arc_office.png" alt="img"></p>
<ul>
<li>docker daemon就是docker的守护进程即server端，可以是远程的，也可以是本地的，这个不是C/S架构吗，客户端Docker client 是通过rest api进行通信</li>
<li>docker cli 用来管理容器和镜像，客户端提供一个只读镜像，然后通过镜像可以创建多个容器，这些容器可以只是一个RFS（Root file system根文件系统），也可以ishi一个包含了用户应用的RFS，容器再docker client中只是要给进程，两个进程之间互不可见</li>
<li>用户不能与server直接交互，但可以通过与容器这个桥梁来交互，由于是操作系统级别的虚拟技术，中间的损耗几乎可以不技</li>
</ul>
<p><strong>简单</strong></p>
<img src="/blog/images/linux/docker/introduction/arc_simple.jpg" width="800px">

<ul>
<li>distribution 负责与docker registry交互，上传洗澡镜像以及v2 registry 有关的源数据</li>
<li>registry负责docker registry有关的身份认证、镜像查找、镜像验证以及管理registry mirror等交互操作</li>
<li>image 负责与镜像源数据有关的存储、查找，镜像层的索引、查找以及镜像tar包有关的导入、导出操作</li>
<li>reference负责存储本地所有镜像的repository和tag名，并维护与镜像id之间的映射关系</li>
<li>layer模块负责与镜像层和容器层源数据有关的增删改查，并负责将镜像层的增删改查映射到实际存储镜像层文件的graphdriver模块</li>
<li>graghdriver是所有与容器镜像相关操作的执行者</li>
</ul>
<p><strong>详细</strong></p>
<p><img src="/blog/images/linux/docker/introduction/arc_detial.jpg" alt="img"></p>
<p>从上图不难看出，用户是使用Docker Client与Docker Daemon建立通信，并发送请求给后者。</p>
<ul>
<li>Docker Daemon作为Docker架构中的主体部分，首先提供Server的功能使其可以接受Docker Client的请求；而后Engine执行Docker内部的一系列工作，每一项工作都是以一个Job的形式的存在。</li>
<li>Job的运行过程中，当需要容器镜像时，则从Docker Registry中下载镜像，并通过镜像管理驱动graphdriver将下载镜像以Graph的形式存储；当需要为Docker创建网络环境时，通过网络管理驱动networkdriver创建并配置Docker容器网络环境；当需要限制Docker容器运行资源或执行用户指令等操作时，则通过execdriver来完成。</li>
<li>libcontainer是一项独立的容器管理包，networkdriver以及execdriver都是通过libcontainer来实现具体对容器进行的操作。当执行完运行容器的命令后，一个实际的Docker容器就处于运行状态，该容器拥有独立的文件系统，独立并且安全的运行环境等。</li>
</ul>
<h3 id="2-4-docker的目标"><a href="#2-4-docker的目标" class="headerlink" title="2-4.docker的目标"></a>2-4.docker的目标</h3><p>docker的主要目标是<code>Build,Ship and Run any App,Angwhere</code>, 构建，运输，处处运行</p>
<ul>
<li><strong>构建</strong>：做一个docker镜像</li>
<li><strong>运输</strong>：docker pull</li>
<li><strong>运行</strong>：启动一个容器</li>
</ul>
<p>每一个容器，它都有自己的文件系统rootfs.</p>
<p>容器化越来越受欢迎原因：</p>
<ul>
<li>灵活：即使是最复杂的应用也可以集装箱化。</li>
<li>轻量级：容器利用/共享主机内核。</li>
<li>可互换：您可以即时部署更新和升级。</li>
<li>便携式：您可以在本地构建，部署到云，并在任何地方运行。</li>
<li>可扩展：您可以增加并自动分发容器副本。</li>
<li>可堆叠：您可以垂直和即时堆叠服务。</li>
</ul>
<h2 id="3-安装Docker"><a href="#3-安装Docker" class="headerlink" title="3.安装Docker"></a>3.安装Docker</h2><h3 id="3-1-安装"><a href="#3-1-安装" class="headerlink" title="3-1.安装"></a>3-1.安装</h3><ul>
<li><a href="https://www.iworkh.com/book/ops/iworkh-ops-docker/docs/#/zh-cn/1-2-dockder-install" target="_blank" rel="noopener">iworkh-docker-安装</a></li>
</ul>
<p>环境说明</p>
<p><strong>docker01</strong></p>
<pre><code class="shell"># 需要两台几点进行安装
[root@docker01 ~]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 
[root@docker01 ~]# uname  -r 
3.10.0-327.el7.x86_64
[root@docker01 ~]# hostname -I
10.0.0.100 172.16.1.100 </code></pre>
<p><strong>docker02</strong></p>
<pre><code class="shell">[root@docker02 ~]# hostname -I
10.0.0.101 172.16.1.101</code></pre>
<p>在<strong>两个节点</strong>上都进行操作</p>
<pre><code class="shell">wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
sed -i &#39;s#download.docker.com#mirrors.ustc.edu.cn/docker-ce#g&#39; /etc/yum.repos.d/docker-ce.repo
yum install docker-ce -y</code></pre>
<blockquote>
<p>下载并安装</p>
</blockquote>
<p>修改在docker01配置：</p>
<pre><code class="shell"># 修改启动文件，监听远程端口
vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H unix:///var/run/docker.sock -H tcp://10.0.0.100:2375</code></pre>
<p><strong>启动</strong></p>
<pre><code class="shell">systemctl daemon-reload
systemctl enable docker.service 
systemctl restart docker.service
# ps -ef检查进行，是否启动</code></pre>
<p>在docker02测试</p>
<pre><code class="shell">[root@docker02 ~]# docker -H 10.0.0.100 info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 17.12.0-ce
Storage Driver: devicemapper
......</code></pre>
<h3 id="3-2-基础命令操作"><a href="#3-2-基础命令操作" class="headerlink" title="3-2.基础命令操作"></a>3-2.基础命令操作</h3><p><strong>查看docker相关信息</strong></p>
<pre><code class="shell">docker version </code></pre>
<p>结果：</p>
<pre><code class="result">Client:
 Version:    17.12.0-ce
 API version:    1.35
 Go version:    go1.9.2
 Git commit:    c97c6d6
 Built:    Wed Dec 27 20:10:14 2017
 OS/Arch:    linux/amd64
Server:
 Engine:
  Version:    17.12.0-ce
  API version:    1.35 (minimum version 1.12)
  Go version:    go1.9.2
  Git commit:    c97c6d6
  Built:    Wed Dec 27 20:12:46 2017
  OS/Arch:    linux/amd64
  Experimental:    false</code></pre>
<p><strong>配置docker镜像加速</strong></p>
<pre><code class="shell">vi /etc/docker/daemon.json
{
  &quot;registry-mirrors&quot;: [&quot;https://registry.docker-cn.com&quot;]
}    </code></pre>
<blockquote>
<p>Docker 版本在 1.12 或更高</p>
</blockquote>
<h3 id="3-3-启动容器"><a href="#3-3-启动容器" class="headerlink" title="3-3 启动容器"></a>3-3 启动容器</h3><p><strong>启动命令</strong></p>
<pre><code class="shell">docker run -d -p 80:80 nginx</code></pre>
<p>参数说明</p>
<table>
<thead>
<tr>
<th><strong>参数</strong></th>
<th><strong>说明</strong></th>
</tr>
</thead>
<tbody><tr>
<td><strong>run</strong></td>
<td>创建并运行一个容器</td>
</tr>
<tr>
<td><strong>-d</strong></td>
<td>放入后台</td>
</tr>
<tr>
<td><strong>-p</strong></td>
<td>端口映射(物理机端口:docker容器端口)</td>
</tr>
<tr>
<td><strong>nginx</strong></td>
<td>镜像名称</td>
</tr>
</tbody></table>
<p>结果</p>
<pre><code class="shell">Unable to find image &#39;nginx:latest&#39; locally
latest: Pulling from library/nginx
e7bb522d92ff: Pull complete 
6edc05228666: Pull complete 
cd866a17e81f: Pull complete 
Digest: sha256:285b49d42c703fdf257d1e2422765c4ba9d3e37768d6ea83d7fe2043dad6e63d
Status: Downloaded newer image for nginx:latest
8d8f81da12b5c10af6ba1a5d07f4abc041cb95b01f3d632c3d638922800b0b4d
# 容器启动后，在浏览器进行访问测试</code></pre>
<h3 id="3-4-镜像生命周期"><a href="#3-4-镜像生命周期" class="headerlink" title="3-4.镜像生命周期"></a>3-4.镜像生命周期</h3><p><img src="/blog/images/linux/docker/introduction/1190037-20180203180313468-930180890.png" alt="img"> </p>
<h2 id="4-镜像操作"><a href="#4-镜像操作" class="headerlink" title="4 镜像操作"></a>4 镜像操作</h2><h3 id="4-1-搜索仓库镜像"><a href="#4-1-搜索仓库镜像" class="headerlink" title="4-1.搜索仓库镜像"></a>4-1.搜索仓库镜像</h3><p><strong>命令</strong></p>
<pre><code>docker search centos</code></pre><p>列表说明</p>
<table>
<thead>
<tr>
<th><strong>参数</strong></th>
<th><strong>说明</strong></th>
</tr>
</thead>
<tbody><tr>
<td><strong>NAME</strong></td>
<td>镜像名称</td>
</tr>
<tr>
<td><strong>DESCRIPTION</strong></td>
<td>镜像说明</td>
</tr>
<tr>
<td><strong>STARS</strong></td>
<td>点赞数量</td>
</tr>
<tr>
<td><strong>OFFICIAL</strong></td>
<td>是否是官方的</td>
</tr>
<tr>
<td><strong>AUTOMATED</strong></td>
<td>是否是自动构建的</td>
</tr>
</tbody></table>
<p>结果</p>
<pre><code class="result">NAME                      DESCRIPTION                    STARS    OFFICIAL               AUTOMATED
centos                    The official build of CentOS.  3992     [OK]      
ansible/centos7-ansible   Ansible on Centos7             105                              [OK]</code></pre>
<h3 id="4-2-获取镜像"><a href="#4-2-获取镜像" class="headerlink" title="4-2.获取镜像"></a>4-2.获取镜像</h3><p>根据镜像名称拉取镜像</p>
<p><strong>命令</strong></p>
<pre><code class="shell">docker pull centos</code></pre>
<p>结果</p>
<pre><code>Using default tag: latest
latest: Pulling from library/centos
af4b0a2388c6: Downloading  34.65MB/73.67MB</code></pre><p><strong>查看当前主机镜像列表</strong></p>
<pre><code>docker image list </code></pre><p>结果</p>
<pre><code>REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              latest              ff426288ea90        3 weeks ago         207MB
nginx               latest              3f8a4339aadd        5 weeks ago         108MB</code></pre><p>拉第三方镜像方法</p>
<pre><code>docker pull index.tenxcloud.com/tenxcloud/httpd</code></pre><h3 id="4-3-导出镜像"><a href="#4-3-导出镜像" class="headerlink" title="4-3.导出镜像"></a>4-3.导出镜像</h3><pre><code>[root@docker01 ~]# docker image list 
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              latest              ff426288ea90        3 weeks ago         207MB
nginx               latest              3f8a4339aadd        5 weeks ago         108MB</code></pre><p><strong>导出命令</strong></p>
<pre><code class="shell">docker image save centos &gt; docker-centos.tar.gz</code></pre>
<h3 id="4-4-删除镜像"><a href="#4-4-删除镜像" class="headerlink" title="4-4.删除镜像"></a>4-4.删除镜像</h3><p><strong>删除命令</strong></p>
<pre><code class="shell">docker image rm centos:latest</code></pre>
<p>结果</p>
<pre><code>[root@docker01 ~]# docker image list 
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              3f8a4339aadd        5 weeks ago         108MB</code></pre><h3 id="4-5-导入镜像"><a href="#4-5-导入镜像" class="headerlink" title="4-5.导入镜像"></a>4-5.导入镜像</h3><p><strong>导入镜像</strong></p>
<pre><code class="shell">docker image load -i docker-centos.tar.gz  </code></pre>
<p>结果</p>
<pre><code>[root@docker01 ~]# docker image load -i docker-centos.tar.gz  
e15afa4858b6: Loading layer  215.8MB/215.8MB
Loaded image: centos:latest
[root@docker01 ~]# docker image list 
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              latest              ff426288ea90        3 weeks ago         207MB
nginx               latest              3f8a4339aadd        5 weeks ago         108MB</code></pre><h3 id="4-6-查看镜像详情"><a href="#4-6-查看镜像详情" class="headerlink" title="4-6.查看镜像详情"></a>4-6.查看镜像详情</h3><p><strong>命令</strong></p>
<pre><code>docker image inspect centos</code></pre><h2 id="5-容器管理"><a href="#5-容器管理" class="headerlink" title="5.容器管理"></a>5.容器管理</h2><h3 id="5-1-容器的起-停"><a href="#5-1-容器的起-停" class="headerlink" title="5-1.容器的起/停"></a>5-1.容器的起/停</h3><p>最简单的运行一个容器</p>
<pre><code>docker run nginx
docker run -d --name iworkh-nginx -p 8080:80 nginx:     #启动nginx容器</code></pre><blockquote>
<p><code>--name</code>:指定容器名<br><code>-p</code>:指定映射端口</p>
</blockquote>
<p>创建容器，两步走（不常用）</p>
<ul>
<li>create 创建</li>
<li>start 启动</li>
</ul>
<pre><code>[root@docker01 ~]# docker create centos:latest  /bin/bash
bb7f32368ecf0492adb59e20032ab2e6cf6a563a0e6751e58930ee5f7aaef204
[root@docker01 ~]# docker start stupefied_nobel
stupefied_nobel</code></pre><p>快速启动容器方法</p>
<pre><code>docker run  centos:latest  /usr/bin/sleep 20;</code></pre><p><strong>容器内的第一个进程必须一直处于运行的状态，否则这个容器，就会处于退出状态！</strong></p>
<p><strong>查看正在运行的容器</strong></p>
<pre><code class="shell">docker container ls
或
docker ps </code></pre>
<p>结果</p>
<pre><code class="result">[root@docker01 ~]# docker ps 
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
8708e93fd767        nginx               &quot;nginx -g &#39;daemon of…&quot;   6 seconds ago       Up 4 seconds        80/tcp              keen_lewin</code></pre>
<p><strong>查看你容器详细信息/ip</strong></p>
<pre><code>docker container  inspect  容器名称/id</code></pre><p><strong>查看你所有容器（包括未运行的）</strong></p>
<pre><code class="shell">docker ps -a</code></pre>
<p>结果</p>
<pre><code>CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES
8708e93fd767        nginx               &quot;nginx -g &#39;daemon of…&quot;   4 minutes ago       Exited (0) 59 seconds ago                       keen_lewin
f9f3e6af7508        nginx               &quot;nginx -g &#39;daemon of…&quot;   5 minutes ago       Exited (0) 5 minutes ago                        optimistic_haibt
8d8f81da12b5        nginx               &quot;nginx -g &#39;daemon of…&quot;   3 hours ago         Exited (0) 3 hours ago                          lucid_bohr</code></pre><p><strong>停止容器</strong></p>
<pre><code>docker stop 容器名称/id 
或
docker container  kill  容器名称/id</code></pre><h3 id="5-2-进入容器"><a href="#5-2-进入容器" class="headerlink" title="5-2.进入容器"></a>5-2.进入容器</h3><p><strong>启动时进去方法</strong></p>
<pre><code>docker run -it nginx:latest  /bin/bash</code></pre><blockquote>
<p>加-it 可交互终端</p>
</blockquote>
<p>退出/离开容器</p>
<pre><code>`ctrl+p &amp; ctrl+q`</code></pre><p><strong>启动后进入容器的方法</strong></p>
<p>启动一个docker</p>
<pre><code>[root@docker01 ~]# docker run -it centos:latest 
[root@1bf0f43c4d2f /]# ps -ef 
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  0 15:47 pts/0    00:00:00 /bin/bash
root         13      1  0 15:47 pts/0    00:00:00 ps -ef</code></pre><p>attach进入容器，使用pts/0 ，会让所用通过此方法进如放入用户看到同样的操作。</p>
<pre><code class="shell">docker attach 1bf0f43c4d2f</code></pre>
<pre><code>[root@1bf0f43c4d2f /]# ps -ef 
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  0 15:47 pts/0    00:00:00 /bin/bash
root         14      1  0 15:49 pts/0    00:00:00 ps -ef</code></pre><p><strong>exec 进入容器方法（推荐使用）</strong></p>
<pre><code class="shell">docker exec -it clsn1  /bin/bash </code></pre>
<p>结果</p>
<pre><code>[root@docker01 ~]# docker exec -it clsn1  /bin/bash 
[root@b20fa75b4b40 /]# 重新分配一个终端
[root@b20fa75b4b40 /]# ps -ef 
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  0 16:11 pts/0    00:00:00 /bin/bash
root         13      0  0 16:14 pts/1    00:00:00 /bin/bash
root         26     13  0 16:14 pts/1    00:00:00 ps -ef</code></pre><h3 id="5-3-删除容器"><a href="#5-3-删除容器" class="headerlink" title="5-3.删除容器"></a>5-3.删除容器</h3><pre><code>docker rm NAMES/CONTAINER ID 
docker rm -f  `docker ps -a -q`</code></pre><blockquote>
<p>-f 强制删除</p>
</blockquote>
<h3 id="5-4-启动时端口映射"><a href="#5-4-启动时端口映射" class="headerlink" title="5-4.启动时端口映射"></a>5-4.启动时端口映射</h3><p>-p参数端口映射</p>
<pre><code>docker run -d -p 8888:80  nginx:latest 
287bec5c60263166c03e1fc5b0b8262fe76507be3dfae4ce5cd2ee2d1e8a89a9</code></pre><p>不同指定映射方法</p>
<table>
<thead>
<tr>
<th><strong>参数</strong></th>
<th><strong>说明</strong></th>
</tr>
</thead>
<tbody><tr>
<td><strong>-p hostPort:containerPort</strong></td>
<td>端口映射 -p 8080:80</td>
</tr>
<tr>
<td><strong>-p ip:hostPort:containerPort</strong></td>
<td>配置监听地址 -p 10.0.0.100:8080:80</td>
</tr>
<tr>
<td><strong>-p ip::containerPort</strong></td>
<td>随机分配端口 -p 10.0.0.100::80</td>
</tr>
<tr>
<td><strong>-p hostPort:containerPort:udp</strong></td>
<td>指定协议 -p 8080:80:tcp</td>
</tr>
<tr>
<td><strong>-p 81:80 –p 443:443</strong></td>
<td>指定多个</td>
</tr>
</tbody></table>
<p>随机映射</p>
<pre><code>docker run -P （大P）# 需要镜像支持</code></pre><h2 id="6-数据卷的管理"><a href="#6-数据卷的管理" class="headerlink" title="6.数据卷的管理"></a>6.数据卷的管理</h2><h3 id="6-1-挂载时创建卷"><a href="#6-1-挂载时创建卷" class="headerlink" title="6-1.挂载时创建卷"></a>6-1.挂载时创建卷</h3><p>挂载卷</p>
<pre><code>docker run -d -p 80:80 -v /data:/usr/share/nginx/html nginx:latest</code></pre><blockquote>
<p><code>-v</code>参数，指定挂载卷</p>
</blockquote>
<p>容器内站点目录: /usr/share/nginx/html</p>
<p>在宿主机写入数据，查看</p>
<pre><code>[root@docker01 ~]# echo &quot;http://www.nmtui.com&quot; &gt;/data/index.html
[root@docker01 ~]# curl 10.0.0.100
http://www.nmtui.com</code></pre><p>设置共享卷，使用同一个卷启动一个新的容器</p>
<pre><code>[root@docker01 ~]# docker run -d -p 8080:80 -v /data:/usr/share/nginx/html nginx:latest 
351f0bd78d273604bd0971b186979aa0f3cbf45247274493d2490527babb4e42
[root@docker01 ~]# curl 10.0.0.100:8080
http://www.nmtui.com</code></pre><p>查看卷列表</p>
<pre><code>[root@docker01 ~]# docker volume ls
DRIVER              VOLUME NAME</code></pre><h3 id="6-2-创建卷后挂载"><a href="#6-2-创建卷后挂载" class="headerlink" title="6-2.创建卷后挂载"></a>6-2.创建卷后挂载</h3><p>创建一个卷</p>
<pre><code>[root@docker01 ~]# docker volume create 
f3b95f7bd17da220e63d4e70850b8d7fb3e20f8ad02043423a39fdd072b83521
[root@docker01 ~]# docker volume ls 
DRIVER              VOLUME NAME
local               f3b95f7bd17da220e63d4e70850b8d7fb3e20f8ad02043423a39fdd072b83521</code></pre><p>指定卷名 <code>--name xxx</code></p>
<pre><code class="shell">docker volume create --name clsn </code></pre>
<pre><code>[root@docker01 ~]# docker volume ls 
DRIVER              VOLUME NAME
local               clsn
local               f3b95f7bd17da220e63d4e70850b8d7fb3e20f8ad02043423a39fdd072b83521</code></pre><p>查看卷路径</p>
<pre><code>[root@docker01 ~]# docker volume inspect clsn 
[
    {
        &quot;CreatedAt&quot;: &quot;2018-02-01T00:39:25+08:00&quot;,
        &quot;Driver&quot;: &quot;local&quot;,
        &quot;Labels&quot;: {},
        &quot;Mountpoint&quot;: &quot;/var/lib/docker/volumes/clsn/_data&quot;,
        &quot;Name&quot;: &quot;clsn&quot;,
        &quot;Options&quot;: {},
        &quot;Scope&quot;: &quot;local&quot;
    }
]</code></pre><p>使用卷创建</p>
<pre><code>[root@docker01 ~]# docker run -d -p 9000:80 -v clsn:/usr/share/nginx/html nginx:latest 
1434559cff996162da7ce71820ed8f5937fb7c02113bbc84e965845c219d3503
# 宿主机测试
[root@docker01 ~]# echo &#39;blog.nmtui.com&#39; &gt;/var/lib/docker/volumes/clsn/_data/index.html 
[root@docker01 ~]# curl 10.0.0.100:9000
blog.nmtui.com</code></pre><p>设置卷</p>
<pre><code>[root@docker01 ~]# docker run  -d  -P  --volumes-from 079786c1e297 nginx:latest 
b54b9c9930b417ab3257c6e4a8280b54fae57043c0b76b9dc60b4788e92369fb</code></pre><p>查看使用的端口</p>
<pre><code class="shell">netstat -lntup </code></pre>
<p>结果</p>
<pre><code>[root@docker01 ~]# netstat -lntup 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1400/sshd           
tcp        0      0 10.0.0.100:2375         0.0.0.0:*               LISTEN      26218/dockerd       
tcp6       0      0 :::9000                 :::*                    LISTEN      32015/docker-proxy  
tcp6       0      0 :::8080                 :::*                    LISTEN      31853/docker-proxy  
tcp6       0      0 :::80                   :::*                    LISTEN      31752/docker-proxy  
tcp6       0      0 :::22                   :::*                    LISTEN      1400/sshd           
tcp6       0      0 :::32769                :::*                    LISTEN      32300/docker-proxy  
[root@docker01 ~]# curl 10.0.0.100:32769
http://www.nmtui.com</code></pre><h3 id="6-3-容器保存为镜像"><a href="#6-3-容器保存为镜像" class="headerlink" title="6-3.容器保存为镜像"></a>6-3.容器保存为镜像</h3><p>本次是基于docker官方centos 6.8 镜像创建</p>
<blockquote>
<p>官方镜像列表：<a href="https://hub.docker.com/explore/" target="_blank" rel="noopener">https://hub.docker.com/explore/</a></p>
</blockquote>
<p>启动一个centos6.8的镜像</p>
<pre><code>[root@docker01 ~]# docker pull  centos:6.8
[root@docker01 ~]# docker run -it -p 1022:22 centos:6.8  /bin/bash
# 在容器种安装sshd服务，并修改系统密码
[root@582051b2b92b ~]# yum install  openssh-server -y 
[root@582051b2b92b ~]# echo &quot;root:123456&quot; |chpasswd
[root@582051b2b92b ~]#  /etc/init.d/sshd start</code></pre><p>启动完成后镜像ssh连接测试</p>
<p><strong>将容器提交为镜像</strong></p>
<pre><code>docker commit brave_mcclintock  centos6-ssh</code></pre><blockquote>
<p>格式docker commit &lt;容器ID或容器名&gt; [&lt;仓库名&gt;[:&lt;标签&gt;]]</p>
</blockquote>
<p>使用新的镜像启动容器</p>
<pre><code>[root@docker01 ~]# docker run -d  -p 1122:22  centos6-ssh:latest  /usr/sbin/sshd -D 
5b8161fda2a9f2c39c196c67e2eb9274977e7723fe51c4f08a0190217ae93094</code></pre><p>在容器安装httpd服务</p>
<pre><code>[root@5b8161fda2a9 /]#  yum install httpd -y</code></pre><p>编写启动脚本脚本</p>
<pre><code>[root@5b8161fda2a9 /]# cat  init.sh 
#!/bin/bash 
/etc/init.d/httpd start 
/usr/sbin/sshd -D
[root@5b8161fda2a9 /]# chmod +x init.sh 
# 注意执行权限</code></pre><p>再次提交为新的镜像</p>
<pre><code>[root@docker01 ~]# docker commit  5b8161fda2a9 centos6-httpd 
sha256:705d67a786cac040800b8485cf046fd57b1828b805c515377fc3e9cea3a481c1</code></pre><p>启动镜像，做好端口映射。并在浏览器中测试访问</p>
<pre><code>[root@docker01 ~]# docker run -d -p 1222:22 -p 80:80  centos6-httpd /init.sh 
46fa6a06644e31701dc019fb3a8c3b6ef008d4c2c10d46662a97664f838d8c2c</code></pre><h2 id="7-Dockerfile"><a href="#7-Dockerfile" class="headerlink" title="7.Dockerfile"></a>7.Dockerfile</h2><p>Dockerfile构建docker镜像</p>
<blockquote>
<p>官方构建dockerfile文件参考 <a href="https://github.com/CentOS/CentOS-Dockerfiles" target="_blank" rel="noopener">https://github.com/CentOS/CentOS-Dockerfiles</a></p>
</blockquote>
<h3 id="7-1-Dockerfile指令集"><a href="#7-1-Dockerfile指令集" class="headerlink" title="7-1.Dockerfile指令集"></a>7-1.Dockerfile指令集</h3><p>dockerfile主要组成部分：</p>
<blockquote>
<p>   <strong>基础镜像信息</strong> FROM centos:6.8</p>
<p>   <strong>制作镜像操作指令</strong> RUN yum insatll openssh-server -y</p>
<p>   <strong>容器启动时执行指令</strong> CMD [“/bin/bash”]</p>
</blockquote>
<p>dockerfile常用指令：</p>
<blockquote>
<p>   <strong>FROM</strong> :这个镜像的妈妈是谁？（指定基础镜像）</p>
<p>   <strong>MAINTAINER</strong> :告诉别人，谁负责养它？（指定维护者信息，可以没有）</p>
<p>   <strong>RUN</strong> :你想让它干啥（在命令前面加上RUN即可）</p>
<p>   <strong>ADD</strong> :给它点创业资金（COPY文件，会自动解压）</p>
<p>   <strong>WORKDIR</strong> :我是cd,今天刚化了妆（设置当前工作目录）</p>
<p>   <strong>VOLUME</strong> :给它一个存放行李的地方（设置卷，挂载主机目录）</p>
<p>   <strong>EXPOSE</strong> :它要打开的门是啥（指定对外的端口）</p>
<p>   <strong>CMD</strong> :奔跑吧，兄弟！（指定容器启动后的要干的事情）</p>
</blockquote>
<p>dockerfile其他指令： </p>
<blockquote>
<p>  <strong>COPY</strong> :复制文件</p>
<p>  <strong>ENV</strong> :环境变量</p>
<p>  <strong>ENTRYPOINT</strong> :容器启动后执行的命令</p>
</blockquote>
<h3 id="7-2-建一个Dockerfile"><a href="#7-2-建一个Dockerfile" class="headerlink" title="7-2.建一个Dockerfile"></a>7-2.建一个Dockerfile</h3><p>创建第一个Dockerfile文件</p>
<pre><code class="shell"># 创建目录
[root@docker01 base]# cd /opt/base
# 创建Dcokerfile文件，注意大小写
[root@docker01 base]# vim Dockerfile</code></pre>
<p><strong>Dockerfile文件里内容</strong></p>
<pre><code class="dockerfile">FROM centos:6.8
RUN yum install openssh-server -y 
RUN echo &quot;root:123456&quot; |chpasswd
RUN /etc/init.d/sshd start 
CMD [&quot;/usr/sbin/sshd&quot;,&quot;-D&quot;]</code></pre>
<p>构建docker镜像</p>
<pre><code>docker image build  -t centos6.8-ssh . </code></pre><blockquote>
<p><code>-t</code>: 为镜像标签打标签  . 表示当前路径</p>
</blockquote>
<p>使用自构建的镜像启动</p>
<pre><code>[root@docker01 base]# docker run  -d -p 2022:22 centos6.8-ssh 
dc3027d3c15dac881e8e2aeff80724216f3ac725f142daa66484f7cb5d074e7a</code></pre><h3 id="7-3-使用Dcokerfile安装kodexplorer"><a href="#7-3-使用Dcokerfile安装kodexplorer" class="headerlink" title="7-3.使用Dcokerfile安装kodexplorer"></a>7-3.使用Dcokerfile安装kodexplorer</h3><p>Dockerfile文件内容</p>
<pre><code class="dockerfile">FROM centos:6.8
RUN yum install wget unzip php php-gd php-mbstring -y &amp;&amp; yum clean all
# 设置工作目录，之后的操作都在这个目录中
WORKDIR /var/www/html/
RUN wget -c http://static.kodcloud.com/update/download/kodexplorer4.25.zip
RUN unzip kodexplorer4.25.zip &amp;&amp; rm -f kodexplorer4.25.zip
RUN chown -R apache.apache .
CMD [&quot;/usr/sbin/apachectl&quot;,&quot;-D&quot;,&quot;FOREGROUND&quot;]</code></pre>
<p>更多的Dockerfile可以参考官方方法。<a href="https://docs.docker.com/engine/reference/builder/" target="_blank" rel="noopener">Dockerfile reference</a></p>
<h2 id="8-镜像分层"><a href="#8-镜像分层" class="headerlink" title="8.镜像分层"></a>8.镜像分层</h2><p><a href="http://www.maiziedu.com/wiki/cloud/dockerimage/" target="_blank" rel="noopener">参考文档</a></p>
<p>Docker支持通过扩展现有镜像，创建新的镜像。实际上，Docker Hub中99%镜像都是通过在base镜像中安装和配置需要的软件构建出来的。</p>
<p><img src="/blog/images/linux/docker/introduction/1190037-20180203180342031-1621628053.png" alt="img"> </p>
<p>从上图可以看到，新镜像是从base镜像一层一层叠加生成的。每安装一个软件，就在现有镜像的基础上增加一层。</p>
<h3 id="8-1-镜像为什么分层"><a href="#8-1-镜像为什么分层" class="headerlink" title="8-1.镜像为什么分层"></a>8-1.镜像为什么分层</h3><p>镜像分层最大的一个好处就是<strong>共享资源</strong>。</p>
<p>比如说有多个镜像都从相同的 base 镜像构建而来，那么Docker Host 只需在磁盘上保存一份 base 镜像；同时内存中也只需加载一份 base 镜像，就可以为所有容器服务了。而且镜像的每一层都可以被共享。</p>
<p>如果多个容器共享一份基础镜像，当某个容器修改了基础镜像的内容，比如<code>/etc</code>下的文件，这时其他容器的<code>/etc</code>是不会被修改的，修改只会被限制在单个容器内。这就是容器 <strong>Copy-on-Write</strong> 特性。</p>
<h3 id="8-2-可写的容器层"><a href="#8-2-可写的容器层" class="headerlink" title="8-2.可写的容器层"></a>8-2.可写的容器层</h3><p>当容器启动时，一个新的可写层被加载到镜像的顶部。这一层通常被称作<code>容器层</code>，<code>容器层</code>之下的都叫<code>镜像层</code>。</p>
<p><img src="/blog/images/linux/docker/introduction/1190037-20180203180355656-1765414705.png" alt="img"> </p>
<p>所有对容器的改动，无论添加、删除、还是修改文件都只会发生在容器层中。只有<strong>容器层是可写的，容器层下面的所有镜像层都是只读的</strong>。</p>
<h3 id="8-3-容器层细节"><a href="#8-3-容器层细节" class="headerlink" title="8-3.容器层细节"></a>8-3.容器层细节</h3><p>镜像层数量可能会很多，所有镜像层会联合在一起组成一个统一的文件系统。<br>如果不同层中有一个相同路径的文件，比如<code>/a</code>，上层的<code>/a</code>会覆盖下层的<code>/a</code>，也就是说用户只能访问到上层中的文件 /a。在容器层中，用户看到的是一个叠加之后的文件系统。</p>
<table>
<thead>
<tr>
<th><strong>文件的操作</strong></th>
<th><strong>说明</strong></th>
</tr>
</thead>
<tbody><tr>
<td><strong>添加文件</strong></td>
<td>在容器中创建文件时，新文件被添加到容器层中。</td>
</tr>
<tr>
<td><strong>读取文件</strong></td>
<td>在容器中读取某个文件时，Docker会<strong>从上往下依次</strong>在各镜像层中查找此文件。一旦找到，<strong>立即将其复制到容器层</strong>，然后打开并读入内存。</td>
</tr>
<tr>
<td><strong>修改文件</strong></td>
<td>在容器中修改已存在的文件时，Docker 会<strong>从上往下</strong>依次在各镜像层中查找此文件。一旦找到，<strong>立即将其复制到容器层</strong>，然后修改之。</td>
</tr>
<tr>
<td><strong>删除文件</strong></td>
<td>在容器中删除文件时，Docker也是<strong>从上往下</strong>依次在镜像层中查找此文件。找到后，会在容器层中<strong>记录下此删除操作</strong>。（只是记录删除操作）</td>
</tr>
</tbody></table>
<p>只有当需要修改时才复制一份数据，这种特性被称作<code>Copy-on-Write</code>。可见，容器层保存的是镜像变化的部分，不会对镜像本身进行任何修改。</p>
<p>这样就解释了我们前面提出的问题：<strong>容器层记录对镜像的修改，所有镜像层都是只读的，不会被容器修改，所以镜像可以被多个容器共享。</strong></p>
<h2 id="9-zabbix-server"><a href="#9-zabbix-server" class="headerlink" title="9.zabbix-server"></a>9.zabbix-server</h2><p>docker运行zabbix-server</p>
<h3 id="9-1-容器间的互联"><a href="#9-1-容器间的互联" class="headerlink" title="9-1 容器间的互联"></a>9-1 容器间的互联</h3><p>在运行zabbix之前务必要了解容器间互联的方法</p>
<pre><code># 创建一个nginx容器
docker run -d -p 80:80 nginx
# 创建容器，做link，并进入容器中
docker run -it --link quirky_brown:web01 centos-ssh /bin/bash
# 在容器中访问nginx容器可以ping通
ping web01    </code></pre><blockquote>
<p><code>--link</code>可以用来链接2个容器，使得源容器（被链接的容器）和接收容器（主动去链接的容器）之间可以互相通信，并且接收容器可以获取源容器的一些数据，如源容器的环境变量</p>
</blockquote>
<p>命令执行过程</p>
<pre><code># 启动apache容器
[root@docker01 ~]# docker run -d httpd:2.4  
3f1f7fc554720424327286bd2b04aeab1b084a3fb011a785b0deab6a34e56955
^[[A[root@docker01 docker ps -a
CONTAINER ID        IMAGE               COMMAND              CREATED             STATUS              PORTS               NAMES
3f1f7fc55472        httpd:2.4           &quot;httpd-foreground&quot;   6 seconds ago       Up 5 seconds        80/tcp              determined_clarke
# 拉取一个busybox 镜像
[root@docker01 ~]# docker pull busybox 
# 启动容器
[root@docker01 ~]# docker run -it --link determined_clarke:web busybox:latest   /bin/sh 
/ # 
# 使用新的容器访问最初的web容器
/ # ping web 
PING web (172.17.0.2): 56 data bytes
64 bytes from 172.17.0.2: seq=0 ttl=64 time=0.058 ms
^C
--- web ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0.058/0.058/0.058 ms</code></pre><h3 id="9-2-启动zabbix容器"><a href="#9-2-启动zabbix容器" class="headerlink" title="9-2.启动zabbix容器"></a>9-2.启动zabbix容器</h3><p>1、启动一个mysql的容器</p>
<pre><code class="docker">docker run --name mysql-server -t \
      -e MYSQL_DATABASE=&quot;zabbix&quot; \
      -e MYSQL_USER=&quot;zabbix&quot; \
      -e MYSQL_PASSWORD=&quot;zabbix_pwd&quot; \
      -e MYSQL_ROOT_PASSWORD=&quot;root_pwd&quot; \
      -d mysql:5.7 \
      --character-set-server=utf8 --collation-server=utf8_bin</code></pre>
<p>2、启动java-gateway容器监控java服务</p>
<pre><code class="docker">docker run --name zabbix-java-gateway -t \
      -d zabbix/zabbix-java-gateway:latest</code></pre>
<p>3、启动zabbix-mysql容器使用link连接mysql与java-gateway。</p>
<pre><code class="docker">docker run --name zabbix-server-mysql -t \
      -e DB_SERVER_HOST=&quot;mysql-server&quot; \
      -e MYSQL_DATABASE=&quot;zabbix&quot; \
      -e MYSQL_USER=&quot;zabbix&quot; \
      -e MYSQL_PASSWORD=&quot;zabbix_pwd&quot; \
      -e MYSQL_ROOT_PASSWORD=&quot;root_pwd&quot; \
      -e ZBX_JAVAGATEWAY=&quot;zabbix-java-gateway&quot; \
      --link mysql-server:mysql \
      --link zabbix-java-gateway:zabbix-java-gateway \
      -p 10051:10051 \
      -d zabbix/zabbix-server-mysql:latest</code></pre>
<p>4、启动zabbix web显示，使用link连接zabbix-mysql与mysql。</p>
<pre><code class="docker">docker run --name zabbix-web-nginx-mysql -t \
      -e DB_SERVER_HOST=&quot;mysql-server&quot; \
      -e MYSQL_DATABASE=&quot;zabbix&quot; \
      -e MYSQL_USER=&quot;zabbix&quot; \
      -e MYSQL_PASSWORD=&quot;zabbix_pwd&quot; \
      -e MYSQL_ROOT_PASSWORD=&quot;root_pwd&quot; \
      --link mysql-server:mysql \
      --link zabbix-server-mysql:zabbix-server \
      -p 80:80 \
      -d zabbix/zabbix-web-nginx-mysql:latest</code></pre>
<h3 id="9-3-zabbix-API"><a href="#9-3-zabbix-API" class="headerlink" title="9-3.zabbix API"></a>9-3.zabbix API</h3><p>关于zabbix API可以参考官方文档：<a href="https://www.zabbix.com/documentation/3.4/zh/manual/api" target="_blank" rel="noopener">https://www.zabbix.com/documentation/3.4/zh/manual/api</a></p>
<p>1、获取token方法</p>
<pre><code># 获取token
[root@docker02 ~]# curl -s -X POST -H &#39;Content-Type:application/json&#39; -d &#39;
{
&quot;jsonrpc&quot;: &quot;2.0&quot;,
&quot;method&quot;: &quot;user.login&quot;,
&quot;params&quot;: {
&quot;user&quot;: &quot;Admin&quot;,
&quot;password&quot;: &quot;zabbix&quot;
},
&quot;id&quot;: 1
}&#39; http://10.0.0.100/api_jsonrpc.php
{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;result&quot;:&quot;d3be707f9e866ec5d0d1c242292cbebd&quot;,&quot;id&quot;:1}</code></pre><h2 id="10-docker仓库"><a href="#10-docker仓库" class="headerlink" title="10.docker仓库"></a>10.docker仓库</h2><p>仓库：registry</p>
<h3 id="10-1-创建一个普通仓库"><a href="#10-1-创建一个普通仓库" class="headerlink" title="10-1.创建一个普通仓库"></a>10-1.创建一个普通仓库</h3><p>1、创建仓库</p>
<pre><code class="docker">docker run -d -p 5000:5000 --restart=always --name registry -v /opt/myregistry:/var/lib/registry  registry </code></pre>
<p>2、修改配置文件，使之支持http</p>
<pre><code class="shell">[root@docker01 ~]# cat  /etc/docker/daemon.json 
{
  &quot;registry-mirrors&quot;: [&quot;https://registry.docker-cn.com&quot;],
  &quot;insecure-registries&quot;: [&quot;10.0.0.100:5000&quot;]
}</code></pre>
<p>重启docker让修改生效</p>
<pre><code class="docker">systemctl restart  docker.service</code></pre>
<p>3、修改镜像标签</p>
<pre><code class="shell">[root@docker01 ~]# docker tag  busybox:latest  10.0.0.100:5000/clsn/busybox:1.0
[root@docker01 ~]# docker images
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
centos6-ssh                     latest              3c2b1e57a0f5        18 hours ago        393MB
httpd                           2.4                 2e202f453940        6 days ago          179MB
10.0.0.100:5000/clsn/busybox    1.0                 5b0d59026729        8 days ago          1.15MB</code></pre>
<p>4、将新打标签的镜像上传镜像到仓库</p>
<pre><code class="docker">docker push   10.0.0.100:5000/clsn/busybox</code></pre>
<h3 id="10-2-带basic认证的仓库"><a href="#10-2-带basic认证的仓库" class="headerlink" title="10-2.带basic认证的仓库"></a>10-2.带basic认证的仓库</h3><p>1、安装加密工具</p>
<pre><code class="shell">yum install httpd-tools  -y</code></pre>
<p>2、设置认证密码</p>
<pre><code class="shell">mkdir /opt/registry-var/auth/ -p
htpasswd  -Bbn clsn 123456  &gt; /opt/registry-var/auth/htpasswd</code></pre>
<p>3、启动容器，在启动时传入认证参数</p>
<pre><code class="docker">docker run -d -p 5000:5000 -v /opt/registry-var/auth/:/auth/ -e &quot;REGISTRY_AUTH=htpasswd&quot; -e &quot;REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm&quot; -e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd registry</code></pre>
<p>4、使用验证用户测试</p>
<pre><code class="shell"># 登陆用户
[root@docker01 ~]# docker login 10.0.0.100:5000 
Username: clsn  
Password: 123456
Login Succeeded
# 推送镜像到仓库
[root@docker01 ~]# docker push 10.0.0.100:5000/clsn/busybox 
The push refers to repository [10.0.0.100:5000/clsn/busybox]
4febd3792a1f: Pushed 
1.0: digest: sha256:4cee1979ba0bf7db9fc5d28fb7b798ca69ae95a47c5fecf46327720df4ff352d size: 527
#认证文件的保存位置
[root@docker01 ~]# cat .docker/config.json 
{
    &quot;auths&quot;: {
        &quot;10.0.0.100:5000&quot;: {
            &quot;auth&quot;: &quot;Y2xzbjoxMjM0NTY=&quot;
        },
        &quot;https://index.docker.io/v1/&quot;: {
            &quot;auth&quot;: &quot;Y2xzbjpIenNAMTk5Ng==&quot;
        }
    },
    &quot;HttpHeaders&quot;: {
        &quot;User-Agent&quot;: &quot;Docker-Client/17.12.0-ce (linux)&quot;
    }
}</code></pre>
<blockquote>
<p>至此，一个简单的docker镜像仓库搭建完成</p>
</blockquote>
<h2 id="11-docker-compose编排工具"><a href="#11-docker-compose编排工具" class="headerlink" title="11.docker-compose编排工具"></a>11.docker-compose编排工具</h2><h3 id="11-1-安装docker-compose"><a href="#11-1-安装docker-compose" class="headerlink" title="11-1.安装docker-compose"></a>11-1.安装docker-compose</h3><p>安装docker-compose</p>
<pre><code class="shell"># 下载pip软件
yum install -y python2-pip
# 下载 docker-compose
pip install docker-compose</code></pre>
<p>国内开启pip 下载加速：<a href="http://mirrors.aliyun.com/help/pypi" target="_blank" rel="noopener">http://mirrors.aliyun.com/help/pypi</a></p>
<ul>
<li><a href="https://iworkh.gitee.io/blog/2020/05/21/python_install/">iworkh-pip换国源</a></li>
</ul>
<pre><code class="shell">mkdir ~/.pip/
cat &gt; ~/.pip/pip.conf &lt;&lt;&#39;EOF&#39;
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
EOF</code></pre>
<h3 id="11-2-编排启动镜像"><a href="#11-2-编排启动镜像" class="headerlink" title="11-2.编排启动镜像"></a>11-2.编排启动镜像</h3><p>1、创建文件目录</p>
<pre><code class="shell">[root@docker01 ~]# mkdir /opt/my_wordpress/
[root@docker01 ~]# cd /opt/my_wordpress/</code></pre>
<p>2、编写编排文件</p>
<pre><code class="shell">vim docker-compose.yml</code></pre>
<p><strong>docker-compose.yml文件内容</strong></p>
<pre><code class="yaml">version: &#39;3&#39;
services:
   db:
     image: mysql:5.7
     volumes:
       - /data/db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress
   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     volumes:
       - /data/web_data:/var/www/html
     ports: 
       - &quot;8000:80&quot;
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress</code></pre>
<p>3、启动</p>
<pre><code class="docker">#启动方法：
docker-compose up
#后台启动方法：
docker-compose up -d</code></pre>
<p>4、浏览器上访问 <a href="http://10.0.0.100:8000/" target="_blank" rel="noopener">http://10.0.0.100:8000</a></p>
<h3 id="11-3-haproxy代理后端docker容器"><a href="#11-3-haproxy代理后端docker容器" class="headerlink" title="11-3.haproxy代理后端docker容器"></a>11-3.haproxy代理后端docker容器</h3><p>1、修改编排脚本</p>
<pre><code class="shell">vim docker-compose.yml </code></pre>
<p><strong>docker-compose.yml文件内容</strong></p>
<pre><code class="yaml">version: &#39;3&#39;
services:
   db:
     image: mysql:5.7
     volumes:
       - /data/db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress
   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     volumes:
       - /data/web_data:/var/www/html
     ports: 
       - &quot;80&quot;
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress</code></pre>
<p>2、同时启动<strong>两台</strong>wordpress</p>
<pre><code class="docker">docker-compose scale wordpress=2 </code></pre>
<p>结果</p>
<pre><code class="shell">[root@docker01 my_wordpress]# docker-compose scale wordpress=2 
WARNING: The scale command is deprecated. Use the up command with the --scale flag instead.
Starting mywordpress_wordpress_1 ... done
Creating mywordpress_wordpress_2 ... done</code></pre>
<p>3、安装haproxy</p>
<pre><code class="shell">yum install haproxy -y</code></pre>
<p>4、修改haproxy配置文件</p>
<blockquote>
<p>关于配置文件的详细说明，参考：<a href="https://www.cnblogs.com/MacoLee/p/5853413.html" target="_blank" rel="noopener">https://www.cnblogs.com/MacoLee/p/5853413.html</a></p>
</blockquote>
<pre><code class="shell">cp /etc/haproxy/haproxy.cfg{,.bak}
vim /etc/haproxy/haproxy.cfg</code></pre>
<pre><code class="config">global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon
    stats socket /var/lib/haproxy/stats level admin  #支持命令行控制
defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000
listen stats
    mode http
    bind 0.0.0.0:8888
    stats enable
    stats uri     /haproxy-status 
    stats auth    admin:123456
frontend frontend_www_example_com
    bind 10.0.0.100:8000
    mode http
    option httplog
    log global
    default_backend backend_www_example_com
backend backend_www_example_com
    option forwardfor header X-REAL-IP
    option httpchk HEAD / HTTP/1.0
    balance roundrobin
    server web-node1  10.0.0.100:32768 check inter 2000 rise 30 fall 15
    server web-node2  10.0.0.100:32769 check inter 2000 rise 30 fall 15</code></pre>
<p>5、启动haproxy</p>
<pre><code class="shell">systemctl start haproxy
systemctl enable haproxy</code></pre>
<p>6、使用浏览器访问hapeoxy监听的8000端口可以看到负载的情况</p>
<p><img src="/blog/images/linux/docker/introduction/1190037-20180203180443968-707439565.png" alt="img"></p>
<p>7、使用浏览器访问 <a href="http://10.0.0.100:8888/haproxy-status" target="_blank" rel="noopener">http://10.0.0.100:8888/haproxy-status</a></p>
<p>  可以看到后端节点的监控状况，</p>
<p><img src="/blog/images/linux/docker/introduction/1190037-20180203180452109-1127111900.png" alt="img"> </p>
<h3 id="11-4-安装socat"><a href="#11-4-安装socat" class="headerlink" title="11-4 安装socat"></a>11-4 安装socat</h3><p>直接操作socket控制haproxy</p>
<p>1、安装软件</p>
<pre><code class="shell">yum install socat.x86_64 -y</code></pre>
<p>2、查看帮助</p>
<pre><code class="shell">echo &quot;help&quot;|socat stdio /var/lib/haproxy/stats</code></pre>
<p>3、下线后端节点</p>
<pre><code class="shell">echo &quot;disable server backend_www_example_com/web-node2&quot;|socat stdio /var/lib/haproxy/stats</code></pre>
<p>4、上线后端节点</p>
<pre><code class="shell">echo &quot;enable server backend_www_example_com/web-node3&quot;|socat stdio /var/lib/haproxy/stats</code></pre>
<p>5、编写php测试页，放到/data/web_data下，在浏览器中访问可以查看当前的节点</p>
<pre><code class="shell">vim check.php</code></pre>
<pre><code class="html">&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;PHP测试&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;?php  echo &#39;&lt;p&gt;Hello World &lt;/p&gt;&#39;; ?&gt;
        &lt;?php  echo &quot;访问的服务器地址是:&quot;.&quot;&lt;fontcolor=red&gt;&quot;.$_SERVER[&#39;SERVER_ADDR&#39;].&quot;&lt;/font&gt;&quot;.&quot;&lt;br&gt;&quot;;
        echo&quot;访问的服务器域名是:&quot;.&quot;&lt;fontcolor=red&gt;&quot;.$_SERVER[&#39;SERVER_NAME&#39;].&quot;&lt;/font&gt;&quot;.&quot;&lt;br&gt;&quot;;
        ?&gt;
    &lt;/body&gt;
&lt;/html&gt;</code></pre>
<h2 id="12-docker重启容器退出"><a href="#12-docker重启容器退出" class="headerlink" title="12.docker重启容器退出"></a>12.docker重启容器退出</h2><p>重启docker服务，容器全部退出的解决办法？</p>
<h3 id="12-1-自动重启"><a href="#12-1-自动重启" class="headerlink" title="12-1.自动重启"></a>12-1.自动重启</h3><p>在启动是指定自动重启</p>
<pre><code>docker run  --restart=always</code></pre><h3 id="1-12-2-修改默认配置"><a href="#1-12-2-修改默认配置" class="headerlink" title="1.12.2 修改默认配置"></a>1.12.2 修改默认配置</h3><p>修改docker默认配置文件</p>
<p>配置文件<code>/etc/docker/daemon.json</code>里，添加上下面这行</p>
<pre><code>&quot;live-restore&quot;: true</code></pre><p>演示</p>
<pre><code class="shell">[root@docker02 ~]# cat  /etc/docker/daemon.json 
{
  &quot;registry-mirrors&quot;: [&quot;https://registry.docker-cn.com&quot;],
  &quot;graph&quot;: &quot;/opt/mydocker&quot;, # 修改数据的存放目录到/opt/mydocker/，原/var/lib/docker/
  &quot;insecure-registries&quot;: [&quot;10.0.0.100:5000&quot;],
  &quot;live-restore&quot;: true
}</code></pre>
<p>重启生效，只对在此之后启动的容器生效</p>
<pre><code class="shell">systemctl restart  docker.service</code></pre>
<h2 id="13-Docker网络类型"><a href="#13-Docker网络类型" class="headerlink" title="13.Docker网络类型"></a>13.Docker网络类型</h2><p> <img src="/blog/images/linux/docker/introduction/1190037-20180203180512750-529190946.png" alt="img"></p>
<h3 id="13-1-网络类型"><a href="#13-1-网络类型" class="headerlink" title="13-1.网络类型"></a>13-1.网络类型</h3><table>
<thead>
<tr>
<th><strong>类型</strong></th>
<th><strong>说明</strong></th>
</tr>
</thead>
<tbody><tr>
<td><strong>None</strong></td>
<td>不为容器配置任何网络功能，没有网络 –net=none</td>
</tr>
<tr>
<td><strong>Container</strong></td>
<td>与另一个运行中的容器共享Network Namespace，–net=container:containerID</td>
</tr>
<tr>
<td><strong>Host</strong></td>
<td>与主机共享Network Namespace，–net=host</td>
</tr>
<tr>
<td><strong>Bridge</strong></td>
<td>Docker设计的NAT网络模型<strong>（默认类型）</strong></td>
</tr>
</tbody></table>
<p><strong>Bridge</strong>默认docker网络隔离基于网络命名空间，在物理机上创建docker容器时会为每一个docker容器分配网络命名空间，并且把容器IP桥接到物理机的虚拟网桥上。</p>
<h3 id="13-2-None"><a href="#13-2-None" class="headerlink" title="13-2.None"></a>13-2.None</h3><blockquote>
<p>不为容器配置网络功能</p>
</blockquote>
<p>此模式下创建容器是不会为容器配置任何网络参数的，如：容器网卡、IP、通信路由等，全部需要自己去配置。</p>
<pre><code class="shell">[root@docker01 ~]# docker run  -it --network none busybox:latest  /bin/sh 
/ # ip a
1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever</code></pre>
<h3 id="13-3-Container"><a href="#13-3-Container" class="headerlink" title="13-3.Container"></a>13-3.Container</h3><blockquote>
<p>与其他容器共享网络配置(Container）</p>
</blockquote>
<p>此模式和host模式很类似，只是此模式创建<strong>容器共享的是其他容器的IP和端口</strong>而不是物理机，此模式容器自身是不会配置网络和端口，</p>
<p>创建此模式容器进去后，你会发现里边的IP是你所指定的那个容器IP并且端口也是共享的，而且其它还是<strong>互相隔离</strong>的，如进程等。</p>
<pre><code class="shell">[root@docker01 ~]# docker run  -it --network container:mywordpress_db_1  busybox:latest  /bin/sh 
/ # ip a
1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
105: eth0@if106: &lt;BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN&gt; mtu 1500 qdisc noqueue 
    link/ether 02:42:ac:12:00:03 brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.3/16 brd 172.18.255.255 scope global eth0
       valid_lft forever preferred_lft forever</code></pre>
<h3 id="13-4-Host"><a href="#13-4-Host" class="headerlink" title="13-4.Host"></a>13-4.Host</h3><blockquote>
<p>使用宿主机网络</p>
</blockquote>
<p>此模式创建的容器没有自己独立的网络命名空间，是和物理机共享一个Network Namespace，并且共享物理机的所有端口与IP，并且这个模式认为是不安全的。</p>
<pre><code class="docker">docker run  -it --network host  busybox:latest  /bin/sh</code></pre>
<h3 id="13-5-查看网络列表"><a href="#13-5-查看网络列表" class="headerlink" title="13-5.查看网络列表"></a>13-5.查看网络列表</h3><pre><code class="shell">[root@docker01 ~]# docker network list 
NETWORK ID          NAME                  DRIVER              SCOPE
b15e8a720d3b        bridge                bridge              local
345d65b4c2a0        host                  host                local
bc5e2a32bb55        mywordpress_default   bridge              local
ebf76eea91bb        none                  null                local</code></pre>
<h3 id="13-6-配置独立IP"><a href="#13-6-配置独立IP" class="headerlink" title="13-6.配置独立IP"></a>13-6.配置独立IP</h3><blockquote>
<p>用PIPEWORK为docker容器配置独立IP</p>
</blockquote>
<blockquote>
<p>参考文档：<a href="http://blog.csdn.net/design321/article/details/48264825" target="_blank" rel="noopener">http://blog.csdn.net/design321/article/details/48264825</a></p>
</blockquote>
<blockquote>
<p>官方网站：<a href="https://github.com/jpetazzo/pipework" target="_blank" rel="noopener">https://github.com/jpetazzo/pipework</a></p>
</blockquote>
<p>宿主环境：centos7.2</p>
<p><strong>1、安装pipework</strong></p>
<pre><code class="shell">wget https://github.com/jpetazzo/pipework/archive/master.zip
unzip master.zip 
cp pipework-master/pipework  /usr/local/bin/
chmod +x /usr/local/bin/pipework</code></pre>
<p><strong>2、配置桥接网卡</strong></p>
<p>安装桥接工具</p>
<pre><code class="shell">yum install bridge-utils.x86_64 -y</code></pre>
<p>修改网卡配置，实现桥接</p>
<pre><code class="shell"># 修改eth0配置，让br0实现桥接
[root@docker01 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 
TYPE=Ethernet
BOOTPROTO=static
NAME=eth0
DEVICE=eth0
ONBOOT=yes
BRIDGE=br0
[root@docker01 ~]# cat /etc/sysconfig/network-scripts/ifcfg-br0 
TYPE=Bridge
BOOTPROTO=static
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=10.0.0.100
NETMASK=255.255.255.0
GATEWAY=10.0.0.254
DNS1=223.5.5.5
# 重启网络
[root@docker01 ~]# /etc/init.d/network restart</code></pre>
<p><strong>3、运行一个容器镜像测试：</strong></p>
<pre><code class="shell">pipework br0 $(docker run -d -it -p 6880:80 --name  httpd_pw httpd) 10.0.0.220/24@10.0.0.254</code></pre>
<p>在其他主机上测试端口及连通性</p>
<pre><code class="shell">[root@docker01 ~]# curl 10.0.0.220
&lt;html&gt;&lt;body&gt;&lt;h1&gt;It works!&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;
[root@docker01 ~]# ping 10.0.0.220 -c 1
PING 10.0.0.220 (10.0.0.220) 56(84) bytes of data.
64 bytes from 10.0.0.220: icmp_seq=1 ttl=64 time=0.043 ms</code></pre>
<p><strong>4、再运行一个容器，设置网路类型为none</strong></p>
<pre><code class="shell">pipework br0 $(docker run -d -it --net=none --name test httpd:2.4) 10.0.0.221/24@10.0.0.254</code></pre>
<p>进行访问测试</p>
<pre><code class="shell">[root@docker01 ~]# curl 10.0.0.221
&lt;html&gt;&lt;body&gt;&lt;h1&gt;It works!&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;</code></pre>
<p><strong>5、重启容器后需要再次指定：</strong></p>
<pre><code>pipework br0 testduliip  172.16.146.113/24@172.16.146.1
pipework br0 testduliip01  172.16.146.112/24@172.16.146.1</code></pre><h3 id="1-13-7-跨主机通信"><a href="#1-13-7-跨主机通信" class="headerlink" title="1.13.7 跨主机通信"></a>1.13.7 跨主机通信</h3><blockquote>
<p>Docker跨主机通信使用macvlan</p>
</blockquote>
<blockquote>
<p>Dcoker跨主机通信之overlay可以参考：<a href="http://www.cnblogs.com/CloudMan6/p/7270551.html" target="_blank" rel="noopener">http://www.cnblogs.com/CloudMan6/p/7270551.html</a></p>
</blockquote>
<p>创建网络</p>
<pre><code class="shell">[root@docker01 ~]# docker network  create --driver macvlan  --subnet 10.1.0.0/24 --gateway 10.1.0.254 -o parent=eth0  macvlan_1
33a1f41dcc074f91b5bd45e7dfedabfb2b8ec82db16542f05213839a119b62ca</code></pre>
<p>设置网卡为混杂模式</p>
<pre><code class="shell">ip link set eth0 promisc on</code></pre>
<p>创建使用macvlan网络容器</p>
<pre><code class="docker">docker run  -it --network macvlan_1  --ip=10.1.0.222 busybox /bin/sh</code></pre>
<h2 id="14-镜像仓库harbor"><a href="#14-镜像仓库harbor" class="headerlink" title="14.镜像仓库harbor"></a>14.镜像仓库harbor</h2><p>docker企业级镜像仓库harbor</p>
<p><strong>容器管理</strong></p>
<pre><code class="shell">[root@docker01 harbor]# pwd
/opt/harbor
[root@docker01 harbor]# docker-compose stop</code></pre>
<p>1、安装docker、docker-compose</p>
<p>下载 harbor</p>
<pre><code class="shell">cd /opt &amp;&amp; https://storage.googleapis.com/harbor-releases/harbor-offline-installer-v1.3.0.tgz
tar xf harbor-offline-installer-v1.3.0.tgz</code></pre>
<p>2、修改主机及web界面密码</p>
<pre><code class="shell">[root@docker01 harbor]# vim harbor.cfg 
    ······
    hostname = 10.0.0.100
    harbor_admin_password = Harbor12345
    ······</code></pre>
<p>3、执行安装脚本</p>
<pre><code class="shell">[root@docker01 harbor]# ./install.sh</code></pre>
<p>浏览器访问 <a href="http://10.0.0.11" target="_blank" rel="noopener">http://10.0.0.11</a></p>
<p><img src="/blog/images/linux/docker/introduction/1190037-20180203180540421-2093222305.png" alt="img"> </p>
<p>添加一个项目</p>
<p><img src="/blog/images/linux/docker/introduction/1190037-20180203180546390-776847142.png" alt="img"></p>
<p>4、镜像推送到仓库的指定项目</p>
<pre><code class="shell">[root@docker02 ~]# docker  tag centos:6.8  10.0.0.100/clsn/centos6.8:1.0
[root@docker02 ~]#  
[root@docker02 ~]# docker images 
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
busybox                     latest              5b0d59026729        8 days ago          1.15MB
10.0.0.100/clsn/centos6.8   1.0                 6704d778b3ba        2 months ago        195MB
centos                      6.8                 6704d778b3ba        2 months ago        195MB
[root@docker02 ~]# docker login 10.0.0.100
Username: admin
Password: 
Login Succeeded</code></pre>
<p>5、推送镜像</p>
<pre><code>[root@docker02 ~]# docker push 10.0.0.100/clsn/centos6.8 
The push refers to repository [10.0.0.100/clsn/centos6.8]
e00c9229b481: Pushing  13.53MB/194.5MB</code></pre><p>6、在web界面里查看</p>
<p><img src="/blog/images/linux/docker/introduction/1190037-20180203180555281-1909245260.png" alt="img"> </p>
<h3 id="14-1-建议"><a href="#14-1-建议" class="headerlink" title="14-1.建议"></a>14-1.建议</h3><p><strong>使用容器的建议</strong></p>
<ol>
<li>不要以拆分方式进行应用程序发布</li>
<li>不要创建大型镜像</li>
<li>不要在单个容器中运行多个进程</li>
<li>不要在镜像内保存凭证，不要依赖IP地址</li>
<li>以非root用户运行进程</li>
<li>不要使用最新标签</li>
<li>不要利用运行中的容器创建镜像</li>
<li>不要使用单层镜像</li>
<li>不要将数据存放在容器内</li>
</ol>
<h3 id="14-2-容器的监控"><a href="#14-2-容器的监控" class="headerlink" title="14-2.容器的监控"></a>14-2.容器的监控</h3><p><strong>容器的基本信息</strong></p>
<p>包括容器的数量、ID、名称、镜像、启动命令、端口等信息</p>
<p><strong>容器的运行状态</strong></p>
<p>统计各状态的容器的数量，包括运行中、暂停、停止及异常退出</p>
<p><strong>容器的用量信息</strong></p>
<p>统计容器的CPU使用率、内存使用量、块设备I/O使用量、网络使用情况等资源的使用情况</p>
<h2 id="15-参考文献"><a href="#15-参考文献" class="headerlink" title="15.参考文献"></a>15.参考文献</h2><blockquote>
<p> [1] <a href="https://www.redhat.com/zh/topics/containers/whats-a-linux-container" target="_blank" rel="noopener">https://www.redhat.com/zh/topics/containers/whats-a-linux-container</a><br> [2] <a href="https://www.redhat.com/zh/topics/containers/what-is-docker" target="_blank" rel="noopener">https://www.redhat.com/zh/topics/containers/what-is-docker</a><br> [3] <a href="http://blog.51cto.com/dihaifeng/1713512" target="_blank" rel="noopener">http://blog.51cto.com/dihaifeng/1713512</a><br> [4] <a href="https://www.cnblogs.com/Bourbon-tian/p/6867796.html" target="_blank" rel="noopener">https://www.cnblogs.com/Bourbon-tian/p/6867796.html</a><br> [5] <a href="https://www.cnblogs.com/CloudMan6/p/6806193.html" target="_blank" rel="noopener">https://www.cnblogs.com/CloudMan6/p/6806193.html</a><br> [🐂6] <a href="https://www.cnblogs.com/clsn/p/8410309.html" target="_blank" rel="noopener">https://www.cnblogs.com/clsn/p/8410309.html</a><br> [🐂7] <a href="https://www.cnblogs.com/zhangxingeng/p/11236968.html" target="_blank" rel="noopener">https://www.cnblogs.com/zhangxingeng/p/11236968.html</a><br> [🐂8] <a href="https://draveness.me/docker/" target="_blank" rel="noopener">https://draveness.me/docker/</a></p>
</blockquote>

      
       <hr><span style="font-style: italic;color: gray;"> 转载请注明来源，欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论，也可以邮件至 157162006@qq.com </span>
    </div>
</article>


<p>
    <a  class="dashang" onclick="dashangToggle()">赏</a>
</p>


<div class="article_copyright">
    <p><span class="copy-title">文章标题:</span>👍docker入门看这一篇就够了</p>
    <p><span class="copy-title">字数:</span><span class="post-count">10.6k</span></p>
    <p><span class="copy-title">本文作者:</span><a  title="沐雨云楼">沐雨云楼</a></p>
    <p><span class="copy-title">发布时间:</span>2020-06-02, 22:22:30</p>
    <p><span class="copy-title">最后更新:</span>2020-09-12, 21:21:47</p>
    <span class="copy-title">原始链接:</span><a class="post-url" href="/blog/2020/06/02/docker-introduction/" title="👍docker入门看这一篇就够了">https://iworkh.gitee.io/blog/2020/06/02/docker-introduction/</a>
    <p>
        <span class="copy-title">版权声明:</span><i class="fa fa-creative-commons"></i> <a rel="license noopener" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank" title="CC BY-NC-SA 4.0 International" target = "_blank">&#34;署名-非商用-相同方式共享 4.0&#34;</a> 转载请保留原文链接及作者。
    </p>
</div>



    <div id="comments"></div>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.css">

<script type="text/javascript">
    $.getScript('/blog/js/gitalk.js', function () {
        var gitalk = new Gitalk({
            clientID: 'e4a269e1ae1600031361',
            clientSecret: '6f3f981cbc49dd802fde779697d8f01da3a77981',
            repo: 'iworkh.github.io',
            owner: 'iworkh',
            admin: ['iworkh'],
            id: decodeURI(location.pathname),
            distractionFreeMode: 'true',
            language: 'zh-CN',
            perPage: parseInt('10',10)
        })
        gitalk.render('comments')
    })
</script>




    




    </div>
    <div class="copyright">
        <p class="footer-entry">©2020 iworkh</p>
<!--<p class="footer-entry">Built with <a href="https://hexo.io/" target="_blank">Hexo</a> and <a href="https://github.com/yelog/hexo-theme-3-hexo" target="_blank">3-hexo</a> theme</p>-->

    </div>
    <div class="full-toc">
        <button class="full" data-title="切换全屏 快捷键 s"><span class="min "></span></button>
<button class="post-toc-menu" data-title="打开TOC 快捷键 w"><span class="post-toc-menu-icons"></span></button>
<div class="post-toc"><span class="post-toc-title">目录</span>
    <div class="post-toc-content">

    </div>
</div>
<a class="" id="rocket" ></a>

    </div>
</div>
<div class="acParent"></div>

<div class="hide_box" onclick="dashangToggle()"></div>
<div class="shang_box">
    <a class="shang_close"  onclick="dashangToggle()">×</a>
    <div class="shang_tit">
        <p>喜欢就点赞,疼爱就打赏</p>
    </div>
    <div class="shang_payimg">
        <div class="pay_img">
            <img src="/blog/img/alipay.jpg" class="alipay" title="扫码支持">
            <img src="/blog/img/weixin.jpg" class="weixin" title="扫码支持">
        </div>
    </div>
    <div class="shang_payselect">
        <span><label><input type="radio" name="pay" checked value="alipay">支付宝</label></span><span><label><input type="radio" name="pay" value="weixin">微信</label></span>
    </div>
</div>


</body>
<script src="/blog/js/jquery.pjax.js?v=1.0.1" ></script>

<script src="/blog/js/script.js?v=1.0.1" ></script>
<script>
    var img_resize = 'default';
    /*作者、标签的自动补全*/
    $(function () {
        $('.search').AutoComplete({
            'data': ['@沐雨云楼','@iworkh','#ai','#attr','#aysnc','#beanmap','#bigdecimal','#blog','#chrome','#dict','#dll','#docker','#domain','#fastjson','#func','#git','#github','#hadoop','#hexo','#idea','#iworkh','#jackson','#java','#jdni','#jfinalshell','#joplin','#JPA','#lock','#markdowm','#maven','#mock','#mq','#mycat','#mysql','#nginx','#notebook','#plan','#powermock','#python','#redis','#rest','#sharding-jdbc','#spark','#springboot','#test','#tool','#tools','#tornado','#transactional','#web','#windows','#wtforms','#zookeeper','#分库分表','#分页','#命令','#工具','#并发','#序列化','#微服务','#性能分析','#手册','#有道云','#标签','#模板','#百度云盘','#结构和算法','#计划','#迁移','#面试',],
            'itemHeight': 20,
            'width': 418
        }).AutoComplete('show');
    })
    function initArticle() {
        /*渲染对应的表格样式*/
        
            $(".post .pjax table").addClass("green_title");
        

        /*渲染打赏样式*/
        
        $("input[name=pay]").on("click", function () {
            if($("input[name=pay]:checked").val()=="weixin"){
                $(".shang_box .shang_payimg .pay_img").addClass("weixin_img");
            } else {
                $(".shang_box .shang_payimg .pay_img").removeClass("weixin_img");
            }
        })
        

        /*高亮代码块行号*/
        
        $('pre code').each(function(){
            var lines = $(this).text().trim().split('\n').length, widther='';
            if (lines>99) {
                widther = 'widther'
            }
            var $numbering = $('<ul/>').addClass('pre-numbering ' + widther).attr("unselectable","on");
            $(this).addClass('has-numbering ' + widther)
                    .parent()
                    .append($numbering);
            for(var i=1;i<=lines;i++){
                $numbering.append($('<li/>').text(i));
            }
        });
        

        /*访问数量*/
        
        $.getScript("//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js");
        

        /*代码高亮，行号对齐*/
        $('.pre-numbering').css('line-height',$('.has-numbering').css('line-height'));

        
        
    }

    /*打赏页面隐藏与展示*/
    
    function dashangToggle() {
        $(".shang_box").fadeToggle();
        $(".hide_box").fadeToggle();
    }
    

</script>

<!--加入行号的高亮代码块样式-->

<style>
    pre{
        position: relative;
        margin-bottom: 24px;
        border-radius: 10px;
        border: 1px solid #e2dede;
        background: #FFF;
        overflow: hidden;
    }
    code.has-numbering{
        margin-left: 30px;
    }
    code.has-numbering.widther{
        margin-left: 35px;
    }
    .pre-numbering{
        margin: 0px;
        position: absolute;
        top: 0;
        left: 0;
        width: 20px;
        padding: 0.5em 3px 0.7em 5px;
        border-right: 1px solid #C3CCD0;
        text-align: right;
        color: #AAA;
        background-color: #fafafa;
    }
    .pre-numbering.widther {
        width: 35px;
    }
</style>

<!--自定义样式设置-->
<style>
    
    
    .nav {
        width: 442px;
    }
    .nav.fullscreen {
        margin-left: -442px;
    }
    .nav-left {
        width: 120px;
    }
    
    
    @media screen and (max-width: 1468px) {
        .nav {
            width: 442px;
        }
        .nav.fullscreen {
            margin-left: -442px;
        }
        .nav-left {
            width: 150px;
        }
    }
    
    
    @media screen and (max-width: 1024px) {
        .nav {
            width: 442px;
            margin-left: -442px
        }
        .nav.fullscreen {
            margin-left: 0;
        }
        .nav .hide-list.fullscreen {
            left: 442px
        }
    }
    
    @media screen and (max-width: 426px) {
        .nav {
            width: 100%;
        }
        .nav-left {
            width: 100%;
        }
    }
    
    
    .nav-right .title-list nav a .post-title, .nav-right .title-list #local-search-result a .post-title {
        color: #383636;
    }
    
    
    .nav-right .title-list nav a .post-date, .nav-right .title-list #local-search-result a .post-date {
        color: #5e5e5f;
    }
    
    
    .nav-right nav a.hover, #local-search-result a.hover{
        background-color: #e2e0e0;
    }
    
    

    /*列表样式*/
    
    .post .pjax article .article-entry>ol, .post .pjax article .article-entry>ul, .post .pjax article>ol, .post .pjax article>ul{
        border: #e2dede solid 1px;
        border-radius: 10px;
        padding: 10px 32px 10px 56px;
    }
    .post .pjax article .article-entry li>ol, .post .pjax article .article-entry li>ul,.post .pjax article li>ol, .post .pjax article li>ul{
        padding-top: 5px;
        padding-bottom: 5px;
    }
    .post .pjax article .article-entry>ol>li, .post .pjax article .article-entry>ul>li,.post .pjax article>ol>li, .post .pjax article>ul>li{
        margin-bottom: auto;
        margin-left: auto;
    }
    .post .pjax article .article-entry li>ol>li, .post .pjax article .article-entry li>ul>li,.post .pjax article li>ol>li, .post .pjax article li>ul>li{
        margin-bottom: auto;
        margin-left: auto;
    }
    

    /* 背景图样式 */
    
    


    /*引用块样式*/
    

    /*文章列表背景图*/
    

    
</style>






<div class="mobile-menus-out" >

</div>
<div class="mobile-menus">
    
    
    
    <a class="dynamic-menu " target="_blank"  href="https://pgmanor.gitee.io/blog/">pgmanor</a>
    
    
    <a class="dynamic-menu " target="_blank"  href="https://www.iworkh.com/manualIt/Category/scopeDev/">iworkh</a>
    
    
    <a class="dynamic-menu " target="_blank"  href="https://gitee.com/iworkh">gitee</a>
    
</div>


<div style="position:absolute; bottom: 0; right: 0;">
    <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=150 height=40 src="//music.163.com/outchain/player?type=2&id=1323150930&auto=0&height=32"></iframe>
</div>

</html>
